class ExceptionHandler extends ExceptionHandler

deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.

ExceptionHandler converts an exception to a Response object.

Methods

__construct($debug = true, $charset = null, $fileLinkFormat = null)

No description

register(bool $debug = true, string|null $charset = null, string|null $fileLinkFormat = null)

Registers the exception handler.

callable|null
setHandler(callable $handler)

Sets a user exception handler.

string
setFileLinkFormat(string $format)

Sets the format for links to source files.

handle(Exception $exception)

Sends a response for the given Exception.

sendPhpResponse(Exception|FlattenException $exception)

Sends the error associated with the given Exception as a plain PHP response.

createResponse(Exception|FlattenException $exception) deprecated

Creates the error Response associated with the given Exception.

string
getHtml(Exception|FlattenException $exception)

Gets the full HTML content associated with the given exception.

string
getContent(FlattenException $exception)

Gets the HTML content associated with the given exception.

string
getStylesheet(FlattenException $exception)

Gets the stylesheet associated with the given exception.

catchOutput($buffer)

No description

cleanOutput($buffer)

No description

Details

in ExceptionHandler at line line 39
__construct($debug = true, $charset = null, $fileLinkFormat = null)

Parameters

$debug
$charset
$fileLinkFormat

in ExceptionHandler at line line 63
static ExceptionHandler register(bool $debug = true, string|null $charset = null, string|null $fileLinkFormat = null)

Registers the exception handler.

Parameters

bool $debug Enable/disable debug mode, where the stack trace is displayed
string|null $charset The charset used by exception messages
string|null $fileLinkFormat The IDE link template

Return Value

ExceptionHandler The registered exception handler

in ExceptionHandler at line line 83
callable|null setHandler(callable $handler)

Sets a user exception handler.

Parameters

callable $handler An handler that will be called on Exception

Return Value

callable|null The previous exception handler if any

in ExceptionHandler at line line 101
string setFileLinkFormat(string $format)

Sets the format for links to source files.

Parameters

string $format The format for links to source files

Return Value

string The previous file link format.

in ExceptionHandler at line line 117
handle(Exception $exception)

Sends a response for the given Exception.

To be as fail-safe as possible, the exception is first handled by our simple exception handler, then by the user exception handler. The latter takes precedence and any output from the former is cancelled, if and only if nothing bad happens in this handling path.

Parameters

Exception $exception

in ExceptionHandler at line line 185
sendPhpResponse(Exception|FlattenException $exception)

Sends the error associated with the given Exception as a plain PHP response.

This method uses plain PHP functions like header() and echo to output the response.

Parameters

Exception|FlattenException $exception An \Exception or FlattenException instance

in ExceptionHandler at line line 211
Response createResponse(Exception|FlattenException $exception) deprecated

deprecated since 2.8, to be removed in 3.0.

Creates the error Response associated with the given Exception.

Parameters

Exception|FlattenException $exception An \Exception or FlattenException instance

Return Value

Response A Response instance

in ExceptionHandler at line line 229
string getHtml(Exception|FlattenException $exception)

Gets the full HTML content associated with the given exception.

Parameters

Exception|FlattenException $exception An \Exception or FlattenException instance

Return Value

string The HTML content as a string

in ExceptionHandler at line line 245
string getContent(FlattenException $exception)

Gets the HTML content associated with the given exception.

Parameters

FlattenException $exception A FlattenException instance

Return Value

string The content as a string

in ExceptionHandler at line line 313
string getStylesheet(FlattenException $exception)

Gets the stylesheet associated with the given exception.

Parameters

FlattenException $exception A FlattenException instance

Return Value

string The stylesheet as a string

in ExceptionHandler at line line 473
catchOutput($buffer)

Parameters

$buffer

in ExceptionHandler at line line 483
cleanOutput($buffer)

Parameters

$buffer