Skip to content

Commit

Permalink
Merge pull request #183 from kudos/watamerrorhandling
Browse files Browse the repository at this point in the history
Add sane handling of errors that happen before the frapi error handler has been initialised
  • Loading branch information
David Coallier committed Nov 1, 2012
2 parents e4e818f + 086bd02 commit ec4b884
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/frapi/library/Frapi/Controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,15 @@ public static function processInternalError(Frapi_Exception $e)
->populateOutput($e->getErrorArray())
->sendHeaders($e)
->executeOutput();
} catch(Frapi_Error $e) {
// If it's just a Frapi_Error, we want to rethrow it.
throw $e;
} catch (Exception $e) {
// This is a hack to intercept anything that may
// have happened before the internal error collection
// during the initialisation process.
//
// If we got here, we have no controller and cannot properly handle
// output, so we just send a 500 and die.

// We have no controller or error handler,
// so send some indication somewhere that things went wrong.
ob_start();
debug_print_backtrace();
error_log(ob_get_clean());

header("HTTP/1.0 500 Internal Server Error");
exit;
Expand Down

0 comments on commit ec4b884

Please sign in to comment.