0

If an exception has been thrown, Symfony 1.4 shows by default the "Oops! An Error Occurred" page. I defined an own page (http://symfony-check.org/permalink/customize-the-oops-an-error-occurred-page) and want to inform me by mail if this happens. So is there any chance to get the thrown exception? Something like error_get_last() ?

Touki
  • 7,465
  • 3
  • 41
  • 63
CrashOverwrite
  • 219
  • 4
  • 14
  • http://stackoverflow.com/questions/7076057/symfony-1-4-how-to-pass-exception-message-to-error-html-php accepted answer in this question has nice solution on custom error handling in sf1.4 – waldek_h Mar 20 '14 at 00:15

1 Answers1

1

Thanks for the suggestion @waldek_c!

Finally I solved the problem with a filter and catch the Exception before the forward to the errorpage. Like this: http://blog.felixdv.com/2008/01/28/exception-catcher-filter-for-symfony/

This is my Filter:

class errorHandlingFilter extends sfFilter
{
public function execute($filterChain)
{
    try
    {
        $filterChain->execute();
    }
    catch(Exception $e)
    {
        if($e instanceof sfStopException || $e instanceof sfError404Exception) // common symfony exceptions that are allowed
        {
            throw $e;
        }
        else
        {
            // do errorhandling here
            throw $e;
        }
    }
}
}
CrashOverwrite
  • 219
  • 4
  • 14