summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2019-02-04 17:34:41 +0100
committerChristian Schneider2019-02-04 17:34:41 +0100
commit641b473a08af61ee57cc56724cf794158a116471 (patch)
treecdc4fd2a8fe92cb0ee8d1769c4bbd30e8b7c8a4e
parentd57c745d402e182c08007f61967a0731c7f9c46f (diff)
downloaditools-641b473a08af61ee57cc56724cf794158a116471.tar.gz
itools-641b473a08af61ee57cc56724cf794158a116471.tar.bz2
itools-641b473a08af61ee57cc56724cf794158a116471.zip
Add global config option $GLOBALS['it_defaultconfig']['fatal_throws_exception'] = true to make it::fatal() throw exception instead of calling exit()
-rw-r--r--it.class11
1 files 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