Since: 7.0

class Error implements Throwable (View source)

Error is the base class for all internal PHP error exceptions.

Properties

protected $message

The error message

protected $code

The error code

protected $file

The filename where the error happened

protected $line

The line where the error happened

Methods

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

Construct the error object.

string
getMessage()

Gets the message

int
getCode()

Gets the exception code

string
getFile()

Gets the file in which the exception occurred

int
getLine()

Gets the line on which the object was instantiated

array
getTrace()

Gets the stack trace

string
getTraceAsString()

Gets the stack trace as a string

null|Throwable
getPrevious()

Returns the previous Throwable

string
__toString()

Gets a string representation of the thrown object

void
__wakeup()

No description

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