{"action":"created","issue":{"url":"https://api.github.com/repos/contao/core-bundle/issues/70","labels_url":"https://api.github.com/repos/contao/core-bundle/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/contao/core-bundle/issues/70/comments","events_url":"https://api.github.com/repos/contao/core-bundle/issues/70/events","html_url":"https://github.com/contao/core-bundle/pull/70","id":63135611,"number":70,"title":"[RFC] Feature/exception listener.","user":{"login":"discordier","id":940331,"avatar_url":"https://avatars.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/contao/core-bundle/labels/feature","name":"feature","color":"4183c4"}],"state":"open","locked":false,"assignee":{"login":"discordier","id":940331,"avatar_url":"https://avatars.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/contao/core-bundle/milestones/1","html_url":"https://github.com/contao/core-bundle/milestones/4.0.0","labels_url":"https://api.github.com/repos/contao/core-bundle/milestones/1/labels","id":748885,"number":1,"title":"4.0.0","description":"Contao 4.0.0 (major release)","creator":{"login":"leofeyer","id":1192057,"avatar_url":"https://avatars.githubusercontent.com/u/1192057?v=3","gravatar_id":"","url":"https://api.github.com/users/leofeyer","html_url":"https://github.com/leofeyer","followers_url":"https://api.github.com/users/leofeyer/followers","following_url":"https://api.github.com/users/leofeyer/following{/other_user}","gists_url":"https://api.github.com/users/leofeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/leofeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leofeyer/subscriptions","organizations_url":"https://api.github.com/users/leofeyer/orgs","repos_url":"https://api.github.com/users/leofeyer/repos","events_url":"https://api.github.com/users/leofeyer/events{/privacy}","received_events_url":"https://api.github.com/users/leofeyer/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":116,"state":"open","created_at":"2014-08-10T18:11:38Z","updated_at":"2015-04-10T11:21:28Z","due_on":"2015-05-25T07:00:00Z","closed_at":null},"comments":16,"created_at":"2015-03-20T01:44:14Z","updated_at":"2015-04-10T18:59:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/70","html_url":"https://github.com/contao/core-bundle/pull/70","diff_url":"https://github.com/contao/core-bundle/pull/70.diff","patch_url":"https://github.com/contao/core-bundle/pull/70.patch"},"body":"This PR is currently a moving target.\r\n\r\nPretty error rendering is enabled by default keep the behaviour known from Contao 3.X.\r\nTo disable it, put the following into your `config_dev.yml`:\r\n```diff\r\n+contao:\r\n+    pretty_error_screens: false\r\n```\r\n\r\nTODO\r\n=====\r\n- [X] Introduce Exception classes for all `die_nicely()` calls.\r\n- [X] Add rendering of exceptions in exception handler.\r\n- [X] Replace occurences of `exit` with proper exception throwing where possible.\r\n- [X] Introduce proper error logging (probably a separate PR). Postponed to future error handling PR.\r\n- [X] ~~Absorb 25dec35453f393debdf9d33c1a53d3a4551429bd from @Toflar's PR for streaming files.~~ Has been merged meanwhile and adjusted accordingly.\r\n- [X] Decide how to handle the error templates.\r\n  - Rewrite using twig! (see 9044208)\r\n  - ~~Drop usage of class `Backend` at least in `be_error` to allow boot exceptions as `be_error.html5` breaks when an exception is encountered before `InitializeSystemListener::boot()` has been called due to `Backend::getTheme()`.~~\r\n  - ~~Unify to a single or at least less templates (see https://github.com/contao/core-bundle/pull/70#issuecomment-87829443).~~\r\n\r\nCaveats and stuff to be aware of:\r\n==========================\r\n1. the error logging is still being set in the `InitializeSystemListener::boot()`.\r\n2. I had to alter the error handling to remove E_NOTICE etc. in the beginning of `InitializeSystemListener::boot()` as otherwise the whole legacy code will break in the console (automator command) as it is riddled with notices.\r\n3. I had to remove the exception and error handlers from `functions.php` as they were rendering the default symfony error and exception handling useless.\r\n4. The whole monolog handling is still missing, I wonder if we should configure it in the standard-distribution and inject the kernel and/or logger into the listener. I am as of now undecided which way to go.\r\n\r\nHow to use the new exceptions:\r\n=========================\r\n\r\nAjax responses with \"No Content\".\r\n----------------------------------------------\r\nOld:\r\n```php\r\n    header('HTTP/1.1 204 No Content');\r\n    header('X-Ajax-Location: ' . $strLocation);\r\n    exit;\r\n```\r\nNew:\r\n```php\r\nthrow AjaxRedirectResponseException::create($location);\r\n```\r\n\r\nRedirect:\r\n----------------------------------------------\r\nOld:\r\n```php\r\n// Simple redirect.\r\nController::redirect($strLocation);\r\n// Simple redirect with status.\r\nController::redirect($strLocation, 301);\r\n```\r\n\r\nNew:\r\n```php\r\n// Simple redirect (HTTP 303).\r\nthrow RedirectResponseException::create($location);\r\n// Simple redirect with status 301.\r\nthrow RedirectResponseException::create($location, 301);\r\n// Provide additional header.\r\nthrow RedirectResponseException::create($location, 301, ['Auth-Token' => 'something']);\r\n```\r\n\r\nFile::sendToBrowser()\r\n----------------------------\r\nFor this one we will use a streaming response to lower load.\r\nFetch code from: 25dec35453f393debdf9d33c1a53d3a4551429bd"},"comment":{"url":"https://api.github.com/repos/contao/core-bundle/issues/comments/91652083","html_url":"https://github.com/contao/core-bundle/pull/70#issuecomment-91652083","issue_url":"https://api.github.com/repos/contao/core-bundle/issues/70","id":91652083,"user":{"login":"discordier","id":940331,"avatar_url":"https://avatars.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T18:59:08Z","updated_at":"2015-04-10T18:59:08Z","body":"I'd promote this to RTM if there are no objections left.\r\nOnly thing remaining to be resolved is https://github.com/contao/core-bundle/pull/70#discussion_r28164826"}}