From 4980e41e67eb7a4ffeb064b696891d5d73fa3efe Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Sat, 29 Apr 2017 07:11:11 +0000 Subject: [PATCH 1/3] github-17: force exit status code 1 and HTTP rc 500 for uncaught exceptions if display_errors=0 --- src/Rollbar.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Rollbar.php b/src/Rollbar.php index 3ba32aaf..25ef6a24 100644 --- a/src/Rollbar.php +++ b/src/Rollbar.php @@ -53,7 +53,15 @@ public static function setupExceptionHandling() public static function exceptionHandler($exception) { - return self::log(Level::error(), $exception); + self::log(Level::error(), $exception); + + if (ini_get('display_errors')) { + restore_exception_handler(); + throw $exception; + } else { + header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); + exit(1); + } } public static function log($level, $toLog, $extra = array()) From 5d15615d6645621ec52fe80c6eea899ad6c87c0d Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Sat, 29 Apr 2017 07:12:38 +0000 Subject: [PATCH 2/3] github-17: composer fix --- src/Rollbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rollbar.php b/src/Rollbar.php index 25ef6a24..efb3e57d 100644 --- a/src/Rollbar.php +++ b/src/Rollbar.php @@ -60,7 +60,7 @@ public static function exceptionHandler($exception) throw $exception; } else { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); - exit(1); + exit(1); } } From 1509e5f915b791ed5520033d182243bd993a563f Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Sat, 29 Apr 2017 07:17:21 +0000 Subject: [PATCH 3/3] github-17: no need to force HTTP rc 500 - default PHP exception handler causes HTTP rc 500 on display_errors=0 by default; just have to restore it after logging with Rollbar --- src/Rollbar.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Rollbar.php b/src/Rollbar.php index efb3e57d..98f2a9e0 100644 --- a/src/Rollbar.php +++ b/src/Rollbar.php @@ -55,13 +55,8 @@ public static function exceptionHandler($exception) { self::log(Level::error(), $exception); - if (ini_get('display_errors')) { - restore_exception_handler(); - throw $exception; - } else { - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); - exit(1); - } + restore_exception_handler(); + throw $exception; } public static function log($level, $toLog, $extra = array())