From 641b473a08af61ee57cc56724cf794158a116471 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 4 Feb 2019 17:34:41 +0100 Subject: Add global config option $GLOBALS['it_defaultconfig']['fatal_throws_exception'] = true to make it::fatal() throw exception instead of calling exit() --- it.class | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/it.class b/it.class index 947f0fe..885dcb6 100644 --- a/it.class +++ b/it.class @@ -163,7 +163,7 @@ static function error($p = array()) return null; # prevent recursion if (!error_reporting() || $p[0] === false || $p['title'] === false) # called with @ or suppressed - return $p['fatal'] ? exit(99) : null; + return $p['fatal'] ? self::_exit($p) : null; if ($_SERVER['REMOTE_ADDR']) $url = "http://" . it::replace([':443$' => ""], $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']; # we ignore https for easier debugging @@ -301,7 +301,7 @@ static function error($p = array()) it::log("/tmp/alertdata/alertlog", $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url" . ($p['body'] ? "\n" . substr(D($p['body']), 0, 5000) . "\n" : "")); - return $p['fatal'] ? exit(99) : null; + return $p['fatal'] ? self::_exit($p) : null; } @@ -324,6 +324,13 @@ static function bail($message = "Bailed.") exit(1); } +static function _exit($p) +{ + if ($GLOBALS['it_defaultconfig']['fatal_throws_exception']) + throw new Exception($p['title']); + exit(99); +} + /** * Check wether I am on a live server for this service. Honors 'aslive' and 'asdevel' debug vars -- cgit v1.2.3