class Error extends Error (View source)

Properties

protected $message

The error message

from  Error
protected $code

The error code

from  Error
protected $file

The filename where the error happened

from  Error
protected $line

The line where the error happened

from  Error

Methods

__construct(string $message = "", int $code = 0, null|Throwable $previous = null)

Construct the error object.

from  Error
string
getMessage()

Gets the message

from  Error
int
getCode()

Gets the exception code

from  Error
string
getFile()

Gets the file in which the exception occurred

from  Error
int
getLine()

Gets the line on which the object was instantiated

from  Error
array
getTrace()

Gets the stack trace

from  Error
string
getTraceAsString()

Gets the stack trace as a string

from  Error
null|Throwable
getPrevious()

Returns the previous Throwable

from  Error
string
__toString()

Gets a string representation of the thrown object

from  Error
void
__wakeup()

No description

from  Error

Details

__construct(string $message = "", int $code = 0, null|Throwable $previous = null)

Construct the error object.

Parameters

string $message

[optional] The Error message to throw.

int $code

[optional] The Error code.

null|Throwable $previous

[optional] The previous throwable used for the exception chaining.

final string getMessage()

Gets the message

Return Value

string

final int getCode()

Since: 7.0

Gets the exception code

Return Value

int

Returns the exception code as integer in {\Exception} but possibly as other type in {\Exception} descendants (for example as string in {\PDOException}).

final string getFile()

Since: 7.0

Gets the file in which the exception occurred

Return Value

string

Returns the name of the file from which the object was thrown.

final int getLine()

Since: 7.0

Gets the line on which the object was instantiated

Return Value

int

Returns the line number where the thrown object was instantiated.

final array getTrace()

Since: 7.0

Gets the stack trace

Return Value

array

Returns the stack trace as an array in the same format as {\debug_backtrace()}.

final string getTraceAsString()

Since: 7.0

Gets the stack trace as a string

Return Value

string

Returns the stack trace as a string.

final null|Throwable getPrevious()

Since: 7.0

Returns the previous Throwable

Return Value

null|Throwable

Returns the previous {\Throwable} if available, or NULL otherwise.

string __toString()

Since: 7.0

Gets a string representation of the thrown object

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

void __wakeup()

No description

Return Value

void