Inside Out

  • Home
  • Categories
    • communities
    • Design
    • Events
    • General
    • inside
    • Links
    • oooday
    • Products
    • SEO
    • Social Media
    • Technology
      • Symfony
    • test
    • Usability
  • Subscribe via RSS

User friendly exception handling with symfony

Alvaro    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.

Share and Enjoy:
  • StumbleUpon
  • Sphinn
  • del.icio.us
  • Facebook
  • TwitThis
  • Google
  • Reddit
  • Digg
  • MisterWong

Responses

Feed Trackback Address
  1. Lukas says:

    December 5th, 2008 at 8:19 am (#)

    What if that module/action is broken too?

  2. Alvaro says:

    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.

  3. rpsblog.com » A week of symfony #101 (1->7 december 2008) says:

    December 8th, 2008 at 1:08 am (#)

    [...] User friendly exception handling with symfony [...]

  4. gustav@gans.de says:

    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

  5. Alvaro says:

    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.

  6. gustav says:

    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.

Leave a Response

Recent Posts

  • Merry Xmas and a happy new year!
  • Openeverything Berlin
  • Short note on ATM usability
  • User friendly exception handling with symfony
  • the NetCircle overheards

Recent Comments

  • gustav on User friendly exception handling with symfony
  • Alvaro on User friendly exception handling with symfony
  • gustav@gans.de on User friendly exception handling with symfony
  • Kent Beatty on Openeverything Berlin
  • rpsblog.com » A week of symfony #101 (1->7 december 2008) on User friendly exception handling with symfony


©2009 Inside Out
Powered by WordPress using the Gridline Lite theme.