zendframework / zend-expressive

PSR-15 middleware in minutes!
BSD 3-Clause "New" or "Revised" License
711 stars 197 forks source link

Configuration for Whoops error handler #124

Closed geerteltink closed 9 years ago

geerteltink commented 9 years ago

When going through the docs I've come up with a basic configuration. The 404 pages do render as expected but the error/error is empty.

return [
    'dependencies' => [
        'invokables' => [
            'Zend\Expressive\Whoops' => Whoops\Run::class,
            'Zend\Expressive\WhoopsPageHandler' => Whoops\Handler\PrettyPageHandler::class,
        ],
        'factories' => [
            'Zend\Expressive\FinalHandler' => Zend\Expressive\Container\WhoopsErrorHandlerFactory::class,
        ],
    ],

    'whoops' => [
        'json_exceptions' => [
            'display'    => true,
            'show_trace' => true,
            'ajax_only'  => true,
        ],
    ],

    'zend-expressive' => [
        'error_handler' => [
            'template_404'   => 'error::404',
            'template_error' => 'error::error',
        ],
    ],
];

When using the TemplatedErrorHandlerFactory it does work as expected (in combination with Twig):

'Zend\Expressive\FinalHandler' => Zend\Expressive\Container\TemplatedErrorHandlerFactory::class,

This is how the error is triggered inside middleware:

return $next($request, $response, new \Exception('Oh no!'));

Did I miss something in the configuration?

geerteltink commented 9 years ago

There is no error handler pushed. That's why the pages are empty on errors. I've created a pull request for this: #125