Interface ExceptionRendererInterface
Base error handler that provides logic common to the CLI + web error/exception handlers.
Subclasses are required to implement the template methods to handle displaying the errors in their environment.
Provide custom logging and error handling.
Debugger overrides PHP's default error handling to provide stack traces and enhanced logging
Error Handler provides basic error and exception handling for your application. It captures and handles all unhandled exceptions and errors. Displays helpful framework errors when debug mode is on.
When debug mode is off a ExceptionRenderer will render 404 or 500 errors. If an uncaught exception is thrown and it is a type that ExceptionRenderer does not know about it will be treated as a 500 error.
You can implement application specific exception handling in one of a few ways. Each approach gives you different amounts of control over the exception handling process.
exceptionRenderer option to inject an Exception renderer. This will
let you keep the existing handling logic but override the rendering logic.This gives you full control over the exception handling process. The class you choose should be loaded in your config/error.php and registered as the default exception handler.
exceptionRendererIf you don't want to take control of the exception handling, but want to change how exceptions are
rendered you can use exceptionRenderer option to choose a class to render exception pages. By default
Cake\Error\ExceptionRenderer is used. Your custom exception renderer class should be placed in src/Error.
Your custom renderer should expect an exception in its constructor, and implement a render method. Failing to do so will cause additional errors.
Using the built-in exception handling, you can log all the exceptions
that are dealt with by ErrorHandler by setting log option to true in your config/error.php.
Enabling this will log every exception to Log and the configured loggers.
Error handler also provides the built in features for handling php errors (trigger_error).
While in debug mode, errors will be output to the screen using debugger. While in production mode,
errors will be logged to Log. You can control which errors are logged by setting
errorLevel option in config/error.php.
When ErrorHandler is used for handling errors, you can enable error logging by setting the log
option to true. This will log all errors to the configured log handlers.
You can control which errors are logged / displayed by ErrorHandler by setting errorLevel. Setting this
to one or a combination of a few of the E_* constants will only enable the specified errors:
$options['errorLevel'] = E_ALL & ~E_NOTICE;
Would enable handling for all non Notice errors.
Exception Renderer.
Captures and handles all unhandled exceptions. Displays helpful framework errors when debug is true. When debug is false a ExceptionRenderer will render 404 or 500 errors. If an uncaught exception is thrown and it is a type that ExceptionHandler does not know about it will be treated as a 500 error.
You can implement application specific exception handling by creating a subclass of
ExceptionRenderer and configure it to be the exceptionRenderer in config/error.php
Using a subclass of ExceptionRenderer gives you full control over how Exceptions are rendered, you can configure your class in your config/app.php.
Represents a fatal error
Wraps a PHP 7 Error object inside a normal Exception so it can be handled correctly by the rest of the error handling system