Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Add an action to show *error* pages in kernel.debug mode#12096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fabpot commentedOct 2, 2014
@weaverryan Can you have a look at this PR. It would be great if we can accept it today or tomorrow for inclusion in 2.6. Thanks. |
mpdude commentedOct 2, 2014
When do you need PRs for symfony/symfony-standard and or -docs at the latest? |
fabpot commentedOct 2, 2014
@mpdude before the end of the week (Sunday.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Was this on accident or am I missing the point of thistry-catch block? Should we just have thereturn new Response part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah, nevermind, I see what you are doing. Why not just create theException and use it - I don't think we need to actually throw it here:
$exception =new \Exception('This is a generic exception being used to help test your error page');returnnewResponse(...);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I was unsure whether this was needed to give the exception for example a "real" stack trace, just in case the error page is to display that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The stack trace is created when the exception is created, so you can remove the try/catch block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just did that :-)
weaverryan commentedOct 2, 2014
@mpdude Thanks for this! First, everything works exactly as advertised and I only spotted one change I can see to make. Second - about yourto be discussed: I understand your point about custom exception messages. In this PR, we just create a generic Do we fix this? As you said, adding a Cheers! |
fabpot commentedOct 3, 2014
👍 Looks good to me. Can you submit a PR on symfony/symfony-standard? |
mpdude commentedOct 3, 2014
Thanks! Seesymfony/symfony-standard#720. |
lyrixx commentedOct 3, 2014
Yeah, this is very simple ! Nice contributions ! |
mpdude commentedOct 3, 2014
I will need another 24h for a docs PR. Can also write up something for the Symfony blog of you like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think this should be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fabpot commentedOct 4, 2014
@mpdude If you can write the blog post the the Symfony blog as well, that would be wonderful. Thanks. |
The docs (http://symfony.com/doc/current/cookbook/controller/error_pages.html) explicitlymentioned subclassing the controller and overriding the showAction method to passadditional variables to the template.The variables are now defined in createResponse(), so I'd like to keep the possibilityto change them. The new testErrorPageAction() method might even work in these cases.
mpdude commentedOct 4, 2014
Doc PR atsymfony/symfony-docs#4293. |
mpdude commentedOct 4, 2014
Here's a suggestion for the blog article:https://gist.github.com/mpdude/ffa505570858e674c62b. |
fabpot commentedOct 5, 2014
Thank you@mpdude. |
…de (mpdude)This PR was squashed before being merged into the 2.6-dev branch (closes#12096).Discussion----------Add an action to show *error* pages in kernel.debug mode| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#7446,#1486,#11327| License | MIT| Doc PR |symfony/symfony-docs#4293See#7446 for the initial reasoning. In short, add to your `routing_development.yml` file the following```yaml_errors: resource: "@TwigBundle/Resources/config/routing/errors.xml" prefix: /_error```Then you can use `http://localhost/app_dev.php/_error/xxx` to preview the HTML *error* page that the default `ExceptionController` (from `TwigBundle`) would pick for the XXX status code.You can also use `http://localhost/app_dev.php/_error/xxx.{some_format}` to show error pages for other formats than HTML, most notably `txt`.Note that the status code will be 500 for all exceptions [that do not implement `HttpExceptionInterface`](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/Exception/FlattenException.php#L47).##### Want to test with a custom exception?~~Folks might want to display (part of) the exception even on error pages and thus need to work with generic (own) exceptions.~~~~They could write an arbitrary controller and throw their exception there. By default, the `ExceptionController` would be used to handle this, only that it would not show *error* pages in `kernel.debug` mode.~~~~Thus, a simple public setter to change the `debug` flag after construction could help. Do we want to add that as well?~~If you want to test error pages with your own exceptions,* create a subclass of `ExceptionController`* set the protected `debug` flag to false* register it as twig.exception_controller in the config* throw your custom exception from any controller.That should give you the error page also in `kernel.debug` mode.##### To-Do- [x] Update docs- [x] Add route in symfony/symfony-defaultCommits-------66ed177 Add an action to show *error* pages in kernel.debug mode
This PR was merged into the 2.6-dev branch.Discussion----------Add route to preview error pages in developmentSeesymfony/symfony#12096 for details.I think this is my first contribution to symfony-standard, does that earn me a badge :-)?Commits-------c7d9f6a Add route to preview error pages in development (see Symfony issue #12096)
This PR was merged into the master branch.Discussion----------Document error page preview (Symfony ~2.6)This adds documentation how to use the new preview feature fromsymfony/symfony#12096 (and hopefully the fix insymfony/symfony#12147).Commits-------d02c7c4 Updates according to GH feedback8e70373 Document error page preview in Symfony ~2.6 (#4293)
See#7446 for the initial reasoning. In short, add to your
routing_development.ymlfile the followingThen you can use
http://localhost/app_dev.php/_error/xxxto preview the HTMLerror page that the defaultExceptionController(fromTwigBundle) would pick for the XXX status code.You can also use
http://localhost/app_dev.php/_error/xxx.{some_format}to show error pages for other formats than HTML, most notablytxt.Note that the status code will be 500 for all exceptionsthat do not implement
HttpExceptionInterface.Want to test with a custom exception?
Folks might want to display (part of) the exception even on error pages and thus need to work with generic (own) exceptions.They could write an arbitrary controller and throw their exception there. By default, theExceptionControllerwould be used to handle this, only that it would not showerror pages inkernel.debugmode.Thus, a simple public setter to change thedebugflag after construction could help. Do we want to add that as well?If you want to test error pages with your own exceptions,
ExceptionControllerdebugflag to falseThat should give you the error page also in
kernel.debugmode.To-Do