Movatterモバイル変換


[0]ホーム

URL:


PHP 8.5.0 Alpha 2 available for testing
    Exception::__construct »
    « Predefined Exceptions

    Exception

    (PHP 5, PHP 7, PHP 8)

    Introduction

    Exception is the base class for all user exceptions.

    Class synopsis

    classExceptionimplementsThrowable {
    /* Properties */
    protectedstring$message = "";
    privatestring$string = "";
    protectedint$code;
    protectedstring$file = "";
    protectedint$line;
    privatearray$trace = [];
    private?Throwable$previous = null;
    /* Methods */
    public__construct(string$message = "",int$code = 0,?Throwable$previous =null)
    finalpublicgetMessage():string
    finalpublicgetPrevious():?Throwable
    finalpublicgetCode():int
    finalpublicgetFile():string
    finalpublicgetLine():int
    finalpublicgetTrace():array
    private__clone():void
    }

    Properties

    message

    The exception message

    code

    The exception code

    file

    The filename where the exception was created

    line

    The line where the exception was created

    previous

    The previously thrown exception

    string

    The string representation of the stack trace

    trace

    The stack trace as an array

    Table of Contents

    Found A Problem?

    Learn How To Improve This PageSubmit a Pull RequestReport a Bug
    add a note

    User Contributed Notes3 notes

    103
    whysteepy at gmail dot com
    7 years ago
    Lists of Throwable and Exception tree as of 7.2.0

    Error
    ArithmeticError
    DivisionByZeroError
    AssertionError
    ParseError
    TypeError
    ArgumentCountError
    Exception
    ClosedGeneratorException
    DOMException
    ErrorException
    IntlException
    LogicException
    BadFunctionCallException
    BadMethodCallException
    DomainException
    InvalidArgumentException
    LengthException
    OutOfRangeException
    PharException
    ReflectionException
    RuntimeException
    OutOfBoundsException
    OverflowException
    PDOException
    RangeException
    UnderflowException
    UnexpectedValueException
    SodiumException

    Find the script and output in the following links:
    https://gist.github.com/mlocati/249f07b074a0de339d4d1ca980848e6a
    https://3v4l.org/sDMsv

    posted by someone herehttp://php.net/manual/en/class.throwable.php
    cHao
    10 years ago
    Note that an exception's properties are populated when the exception is *created*, not when it is thrown. Throwing the exception does not seem to modify them.

    Among other things, this means:

    * The exception will blame the line that created it, not the line that threw it.

    * Unlike in some other languages, rethrowing an exception doesn't muck up the trace.

    * A thrown exception and an unthrown one look basically identical. On my machine, the only visible difference is that a thrown exception has an `xdebug_message` property while an unthrown one doesn't. Of course, if you don't have xdebug installed, you won't even get that.
    shaman_master at list dot ru
    5 years ago
    Note: this documentation not full, ReflectionObject::export($exception):
    <?php
    Object of
    class [ classExceptionimplementsThrowable] {
    -
    Properties[7] {
    Property[ protected$message]
    Property[ private$string]
    Property[ protected$code]
    Property[ protected$file]
    Property[ protected$line]
    Property[ private$trace]
    Property[ private$previous]
    }
    -
    Methods[11] {
    Method[ final privatemethod __clone] {
    }

    Method[ publicmethod __construct] {

    -
    Parameters[3] {
    Parameter#0 [ $message ]
    Parameter#1 [ $code ]
    Parameter#2 [ $previous ]
    }
    }

    Method[ publicmethod __wakeup] {
    }

    Method[ final publicmethod getMessage] {
    }

    Method[ final publicmethod getCode] {
    }

    Method[ final publicmethod getFile] {
    }

    Method[ final publicmethod getLine] {
    }

    Method[ final publicmethod getTrace] {
    }

    Method[ final publicmethod getPrevious] {
    }

    Method[ final publicmethod getTraceAsString] {
    }

    Method[ publicmethod __toString] {
    }
    }
    }
    ?>

    Missed:

    Property [ private $string ]
    Property [ private $trace ]
    Property [ private $previous ]

    Method [ public method __wakeup ] {
    }
    add a note
    To Top
    and to navigate •Enter to select •Esc to close
    PressEnter without selection to search using Google

    [8]ページ先頭

    ©2009-2025 Movatter.jp