Silex Exception handler
php, silex, symfony
Solution
The `error` listener is only able to catch exceptions thrown from within a controller or a `before` middleware. Here's an example that works:
$app = new Silex\Application();
$app->error(function (\Exception $e, $code) {
exit('asd');
});
$app->before(function ($request) {
throw new Exception('test');
});
$app->run();
Problem
I have big problem I don't know why exceptions are not catch by silex exception handler ? My simple Code looks like this: ``` <?php use Silex\Application; use Silex\Provider\ValidatorServiceProvider; use Silex\Provider\FormServiceProvider; use Symfony\Component\HttpFoundation\Request; $app = new Application(); // SPL Logic Exceptions // Handle other exception as 500 errors $app->error(function (\Exception $e, $code) { exit('asd'); }); throw new Exception('test'); return $app; ``` And the result is: Fatal error: Uncaught exception 'Exception' with message 'test'