charm / exception-middleware
Provides a PSR-15 Middleware which traps exceptions and renders a nice error page.
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/charm/exception-middleware
Requires
- charm/interop: ^0.0.1
README
A simple middleware implementation that catches exceptions thrown later in the exception stack and renders a nice error message.
Configuration
$middleware = new ExceptionMiddleware([
    'error_handler' => function(\Throwable $e) {
        if ($e->getCode() === 404) {
            return render_page_not_found();
        }
        // If error handler returns null, the ExceptionMiddleware will render a response.
        return null;
    }
]);