User friendly exception handling with symfony
December 4th, 2008
Alvaro
Published in
Symfony, Technology | 6 Comments
The default behavior in symfony is that if an exception arises and is not handled then it will redirect the user to the error500.php page or show a stack trace. Even if is possible to override the error500.php page, we were in the need to provide custom messages to the user and also keep him inside the symfony application.
Multiple factors can make this problem to happen, like when the database server refuse our connection attempts or just because something went wrong in our php application. To overcome this issue we developed a plugin that tells the symfony exception handling mechanism to forward the user to a module/action specified in the configuration files.
In this way, we can keep with us all the benefits of the symfony rendering engine, all it’s helpers, etc.
The handler is made in such a way that we can specify a global default error action, or more detailed per module/action handlers. We can have all this coolness by just typing a few lines in the module.yml file or in the app.yml file :).
If you want to see the details of the usage please check the plugin page on the symfony website.









December 5th, 2008 at 8:19 am (#)
What if that module/action is broken too?
December 5th, 2008 at 8:52 am (#)
@Lukas, thanks for the feedback. I modified the catcher so if everything fails then finally the user sees the error500.php page or the stack trace, according to the environment.
December 8th, 2008 at 1:08 am (#)
[...] User friendly exception handling with symfony [...]
January 3rd, 2009 at 2:59 pm (#)
iam amused to see thadt the PHP Folk will
follow the Ways of Java. Because, Java need
no Framework to do thadt. It has always the
abilities to do it, without Tricks and PlugIns
;D
January 5th, 2009 at 2:08 am (#)
@gustav: I don’t get what you mean. Exceptions are a feature of the PHP language, so there is no framework needed for that.
http://www.php.net/manual/en/language.exceptions.php
And what our plugin does, is to override the exception handling mechanism of symfony, which is a PHP framework.
January 5th, 2009 at 2:59 pm (#)
Anyway! Java ist better!
It scales better, has a better maintable codebase in
large projects and self Tuning Hotspot VM-System wich
can take the advantages on every OS and every Hardware.