X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Ferrors.inc;h=a54abba810f3adf87d950d29f6c763dd6a5f81da;hb=aec1717f263bf767543afa6bd0cb960ce53e0a0d;hp=c5414d60b92b26aca3d27fa8b641a5b7c2fd7421;hpb=020d309dc37e9400d27ef3cad381e6f1b04f67fd;p=fa-stable.git diff --git a/includes/errors.inc b/includes/errors.inc index c5414d60..a54abba8 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -21,7 +21,8 @@ function get_backtrace($html = false, $skip=0) foreach($trace as $trn => $tr) { if ($trn <= $skip) continue; if ($html) $str .= ''; - $str .= $tr['file'].':'.$tr['line'].': '; + if (isset($tr['file']) && isset($tr['line'])) + $str .= $tr['file'].':'.$tr['line'].': '; if ($html) $str .= ''; if (isset($tr['type'])) { if($tr['type'] == '::') { @@ -32,7 +33,7 @@ function get_backtrace($html = false, $skip=0) } $str .= $tr['function'].'('; - if(is_array($tr['args'])) { + if(isset($tr['args']) && is_array($tr['args'])) { $args = array(); foreach($tr['args'] as $n=>$a) { if (is_object($tr['args'][$n])) @@ -56,7 +57,7 @@ function get_backtrace($html = false, $skip=0) // display in message box. function error_handler($errno, $errstr, $file, $line) { - global $messages, $SysPrefs; + global $messages, $SysPrefs, $cur_error_level; // skip well known warnings we don't care about. // Please use restrainedly to not risk loss of important messages @@ -73,20 +74,29 @@ function error_handler($errno, $errstr, $file, $line) { $bt = isset($SysPrefs) && $SysPrefs->go_debug>1 ? get_backtrace(true, 1) : array(); - // error_reporting==0 when messages are set off with @ - if ($errno & error_reporting()) { - // suppress duplicated errors - if (!in_array(array($errno, $errstr, $file, $line, @$bt), $messages)) - $messages[] = array($errno, $errstr, $file, $line, @$bt); - } - else if ($errno&~E_NOTICE && $errstr != '') { // log all not displayed messages - $user = @$_SESSION["wa_current_user"]->loginname; - $context = isset($SysPrefs) && !$SysPrefs->db_ok ? '[before upgrade]' : ''; - error_log(user_company() . ":$user:". basename($file) .":$line:$context $errstr"); + // error_reporting!=cur_error_level when messages are set off with @ + if ($cur_error_level == error_reporting()) { + if ($errno & $cur_error_level) { + // suppress duplicated errors + if (!in_array(array($errno, $errstr, $file, $line, @$bt), $messages)) + $messages[] = array($errno, $errstr, $file, $line, @$bt); + } + else if ($errno&~E_NOTICE && $errstr != '') { // log all not displayed messages + $user = @$_SESSION["wa_current_user"]->loginname; + $context = isset($SysPrefs) && !$SysPrefs->db_ok ? '[before upgrade]' : ''; + error_log(user_company() . ":$user:". basename($file) .":$line:$context $errstr"); + } } return true; } + +function exception_handler($exception) +{ + error_handler(E_ERROR, sprintf(_("Unhandled exception [%s]: %s."), $exception->getCode(), $exception->getMessage()), + $exception->getFile(), $exception->getLine()); + end_page(); +} //------------------------------------------------------------------------------ // Formats system messages before insert them into message
// FIX center is unused now