{"action":"created","issue":{"url":"https://api.github.com/repos/silexphp/Silex/issues/1016","repository_url":"https://api.github.com/repos/silexphp/Silex","labels_url":"https://api.github.com/repos/silexphp/Silex/issues/1016/labels{/name}","comments_url":"https://api.github.com/repos/silexphp/Silex/issues/1016/comments","events_url":"https://api.github.com/repos/silexphp/Silex/issues/1016/events","html_url":"https://github.com/silexphp/Silex/issues/1016","id":42961679,"number":1016,"title":"Silex doesn't catch fatal errors by the error handler.","user":{"login":"AlexeyKupershtokh","id":499778,"avatar_url":"https://avatars.githubusercontent.com/u/499778?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexeyKupershtokh","html_url":"https://github.com/AlexeyKupershtokh","followers_url":"https://api.github.com/users/AlexeyKupershtokh/followers","following_url":"https://api.github.com/users/AlexeyKupershtokh/following{/other_user}","gists_url":"https://api.github.com/users/AlexeyKupershtokh/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexeyKupershtokh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexeyKupershtokh/subscriptions","organizations_url":"https://api.github.com/users/AlexeyKupershtokh/orgs","repos_url":"https://api.github.com/users/AlexeyKupershtokh/repos","events_url":"https://api.github.com/users/AlexeyKupershtokh/events{/privacy}","received_events_url":"https://api.github.com/users/AlexeyKupershtokh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2014-09-17T04:06:22Z","updated_at":"2016-09-02T14:44:34Z","closed_at":"2015-08-04T13:24:55Z","body":"Hello.\r\nI'm trying to use Symfony\\Component\\Debug\\ErrorHandler in order to handle fatal errors (converted to fatal exceptions) with Silex error callback.\r\n\r\nI've written a minimal script reproducing the situation:\r\n```php\r\n<?php\r\n \r\nrequire_once __DIR__ . '/vendor/autoload.php';\r\n \r\nuse Symfony\\Component\\Debug\\ErrorHandler;\r\n \r\n$app = new Silex\\Application();\r\n \r\n// emulate E_NOTICE\r\n//$app->get('/', function () use ($app) { $a + 1; });\r\n \r\n// emulate fatal error\r\n$app->get('/', function () use ($app) { asd(); });\r\n \r\n$app->error(\r\n    function ($e) use ($app) {\r\n        // notices go here with $e of type\r\n        // $e is instance of \\Symfony\\Component\\Debug\\Exception\\ContextErrorException\r\n        var_dump('silex error handler', get_class($e));\r\n    }\r\n);\r\n \r\nErrorHandler::register();\r\nset_exception_handler(function($e) {\r\n    // fatals come here instead of $app->error callback :(\r\n    // $e is instance of \\Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\r\n    var_dump('exception handler', get_class($e));\r\n});\r\n \r\n$app->run();\r\n```\r\n\r\nWith non-fatal errors-exceptions everything is perfect (uncomment the ```//$app->get('/', function () use ($app) { $a + 1; });``` to test). But fatal errors-exceptions are not bubbled to the error callback but are caught by the set_exception_handler one instead.\r\n\r\nWhat I'm trying to achieve (in larger project) is to have an HTTP API that can return json even on fatal errors. Error handler is the best place to do so and it works well for many cases. I would like to avoid doing something like:\r\n```php\r\nset_exception_handler(function($e) { print json_encode($e->getMessage()); exit(); });\r\n```\r\nIs it possible to rely on Silex in this case?"},"comment":{"url":"https://api.github.com/repos/silexphp/Silex/issues/comments/244395068","html_url":"https://github.com/silexphp/Silex/issues/1016#issuecomment-244395068","issue_url":"https://api.github.com/repos/silexphp/Silex/issues/1016","id":244395068,"user":{"login":"tiemevanveen","id":1330668,"avatar_url":"https://avatars.githubusercontent.com/u/1330668?v=3","gravatar_id":"","url":"https://api.github.com/users/tiemevanveen","html_url":"https://github.com/tiemevanveen","followers_url":"https://api.github.com/users/tiemevanveen/followers","following_url":"https://api.github.com/users/tiemevanveen/following{/other_user}","gists_url":"https://api.github.com/users/tiemevanveen/gists{/gist_id}","starred_url":"https://api.github.com/users/tiemevanveen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiemevanveen/subscriptions","organizations_url":"https://api.github.com/users/tiemevanveen/orgs","repos_url":"https://api.github.com/users/tiemevanveen/repos","events_url":"https://api.github.com/users/tiemevanveen/events{/privacy}","received_events_url":"https://api.github.com/users/tiemevanveen/received_events","type":"User","site_admin":false},"created_at":"2016-09-02T14:44:34Z","updated_at":"2016-09-02T14:44:34Z","body":"Correct. But they also say: \r\n> $app['request'] should NEVER be used and is deprecated."}}
{"actor":{"display_login":"tiemevanveen"}}