foreach($trace as $trn => $tr) {
if ($trn <= $skip) continue;
if ($html) $str .= '<tr><td>';
- $str .= $tr['file'].':'.$tr['line'].': ';
+ if (isset($tr['file']) && isset($tr['line']))
+ $str .= $tr['file'].':'.$tr['line'].': ';
if ($html) $str .= '</td><td>';
if (isset($tr['type'])) {
if($tr['type'] == '::') {
}
$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]))
// 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
}
}
- $bt = $SysPrefs->go_debug>1 ? get_backtrace(true, 1) : array();
+ $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 <div>
// FIX center is unused now