class Error (View source)

Drupal error utility class.

Constants

ERROR

The error severity level.

Properties

static protected array $blacklistFunctions

An array of blacklisted functions.

Methods

static array
decodeException(Exception|Throwable $exception)

Decodes an exception and retrieves the correct caller.

static string
renderExceptionSafe(Exception|Throwable $exception)

Renders an exception error message without further exceptions.

static array
getLastCaller(array $backtrace)

Gets the last caller from a backtrace.

static string
formatBacktrace(array $backtrace)

Formats a backtrace into a plain-text string.

Details

static array decodeException(Exception|Throwable $exception)

Decodes an exception and retrieves the correct caller.

Parameters

Exception|Throwable $exception

The exception object that was thrown.

Return Value

array

An error in the format expected by _drupal_log_error().

static string renderExceptionSafe(Exception|Throwable $exception)

Renders an exception error message without further exceptions.

Parameters

Exception|Throwable $exception

The exception object that was thrown.

Return Value

string

An error message.

static array getLastCaller(array $backtrace)

Gets the last caller from a backtrace.

Parameters

array $backtrace

A standard PHP backtrace. Passed by reference.

Return Value

array

An associative array with keys 'file', 'line' and 'function'.

static string formatBacktrace(array $backtrace)

Formats a backtrace into a plain-text string.

The calls show values for scalar arguments and type names for complex ones.

Parameters

array $backtrace

A standard PHP backtrace.

Return Value

string

A plain-text line-wrapped string ready to be put inside

.