class ExceptionHandler
ExceptionHandler converts an exception to a Response object.
It is mostly useful in debug mode to replace the default PHP/XDebug output with something prettier and more useful.
As this class is mainly used during Kernel boot, where nothing is yet available, the Response content is always HTML.
Methods
__construct($debug = true, $charset = null, $fileLinkFormat = null) | ||
static ExceptionHandler | register(bool $debug = true, string|null $charset = null, string|null $fileLinkFormat = null) Registers the exception handler. | |
callable|null | setHandler(callable $handler = null) 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. | ||
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. |
Details
__construct($debug = true, $charset = null, $fileLinkFormat = null)
static ExceptionHandler register(bool $debug = true, string|null $charset = null, string|null $fileLinkFormat = null)
Registers the exception handler.
callable|null setHandler(callable $handler = null)
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.
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.
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.
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.
Please login to continue.