Permalink
Browse files

Merge pull request #183 from kudos/watamerrorhandling

Add sane handling of errors that happen before the frapi error handler has been initialised
  • Loading branch information...
2 parents e4e818f + 086bd02 commit ec4b88428f8457039f89931b933b3fc0c9b9369c David Coallier committed Nov 1, 2012
Showing with 8 additions and 7 deletions.
  1. +8 −7 src/frapi/library/Frapi/Controller/Api.php
@@ -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;

0 comments on commit ec4b884

Please sign in to comment.