Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Firing action on any not "catched" exception.
  • Hi;

    Maybe this is a more related PHP question than FuelPHP, but i need some help.

    The final objective is catching all exceptions not catched for sending an email with the failure info.

    I decided to put the following code block in the index.php:

    //--- Fragment of index.php (starting in Line 85)
    // Generate the request, execute it and send the output.
    try
    {
       // Boot the app...
       require APPPATH.'bootstrap.php';
       // ... and execute the main request
       $response = $routerequest();
    }
    catch (HttpNoAccessException $e)
    {
       $response = $routerequest('_403_', $e);
    }
    catch (HttpNotFoundException $e)
    {
       $response = $routerequest('_404_', $e);
    }
    catch (HttpServerErrorException $e)
    {
       $response = $routerequest('_500_', $e);
    }
    /* ADDED CODE HERE*/ 
    catch(Exception $e)
    {
    SomeClass::SomeMethod();
    }
    //-- End of fragment

    I do not know if this is the best way to do what I want, or is there another more elegant.
  • HarroHarro
    Accepted Answer
    That is an option.

    But if you want to know what the app is doing, it's perhaps better to attach a mail handler to the log and have it email log entries (for example all warnings or errors).

    See this post on how to setup a custom log handler: http://fuelphp.com/forums/discussion/13671/is-it-possible-to-log-to-database
  • Thanks harro :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion