diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -114,7 +114,7 @@ static function timerlog($label = '') * If display_errors is on or stdout is a tty, shows error in page or on stdout respectively * If display_errors is off, mails (with rate limiting) diagnostics to .diffnotice addresses or file owner or SERVER_ADMIN * @param $p either error title or assoc array of params, see below - * @param $p['title'] error title, one line + * @param $p['title'] error title, one line. also accepted in $p[0] (with priority). false means ignore error * @param $p['body'] error body: multiline string or any data type (will be dumped) * @param $p['to'] comma separated recipient list * @param $p['id'] id of error. if given, first error is suppressed and second has to occur after 'graceperiod' within 'timewindow' @@ -127,6 +127,7 @@ static function timerlog($label = '') * @param $p['okstate'] give current ok label and ok state, e.g. telresult=1 for working. see failcount * @param $p['failcount'] give number of consecutive okstate failures needed for creating an error [2] * @param $p['omitdebuginfo'] value 1 omits long stack and var dumps, value 2 also omits trace and url + * @param $p['fatal'] exit after displaying error * @return always null (so users can return it::error() in error cases) * EXAMPLES (m: mail, x: no mail) * time ---|graceperiod|timewindow| @@ -140,9 +141,10 @@ static function timerlog($label = '') */ static function error($p = array()) { - $p = is_array($p) ? $p : array('title' => $p); + $p = (array)$p; + $p['title'] = $p[0] ?: $p['title']; # handle 'it_error' => "oops" that was cast to array on the way - if (!error_reporting()) # called with @ + if (!error_reporting() || $p[0] === false || $p['title'] === false) # called with @ or suppressed return null; if ($_SERVER['REMOTE_ADDR']) @@ -265,6 +267,13 @@ static function error($p = array()) file_put_contents("/tmp/alertdata/alert.log", date("Y-m-d H:i:s") . " " . $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url\n", FILE_APPEND); @chmod("/tmp/alertdata/alert.log", 0777); + if ($p['fatal']) + { + if ($_SERVER['REMOTE_ADDR']) + header("HTTP/1.0 500 Internal Server Error"); + exit(99); + } + return null; } @@ -275,10 +284,7 @@ static function error($p = array()) */ static function fatal($p) { - it::error(array('backtraceskip' => 2) + (is_array($p) ? $p : array('title' => $p))); - if ($_SERVER['REMOTE_ADDR']) - header("HTTP/1.0 500 Internal Server Error"); - exit(99); + it::error(['fatal' => true, 'backtraceskip' => 2] + (array)$p); } |