Skip to content

Commit e885480

Browse files
authored
Error reporting: indicate the actual level instead of always 'Error' (#1742)
Previously, (just) a warning would be logged as "Error 2 - something" "Error 8192 - use of thing is deprecated" Now this is logged as "Warning - something" "Deprecated - use of thing is deprecated" This should avoid red herrings when debugging an issue when e.g. a warning, notice or even deprecation notice looks like its an actual error while it's not.
1 parent c3937e4 commit e885480

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

www/_include.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,27 @@ function SimpleSAML_error_handler(
6363
return false;
6464
}
6565

66+
$levels = [
67+
\E_DEPRECATED => 'Deprecated',
68+
\E_USER_DEPRECATED => 'User Deprecated',
69+
\E_NOTICE => 'Notice',
70+
\E_USER_NOTICE => 'User Notice',
71+
\E_STRICT => 'Runtime Notice',
72+
\E_WARNING => 'Warning',
73+
\E_USER_WARNING => 'User Warning',
74+
\E_COMPILE_WARNING => 'Compile Warning',
75+
\E_CORE_WARNING => 'Core Warning',
76+
\E_USER_ERROR => 'User Error',
77+
\E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
78+
\E_COMPILE_ERROR => 'Compile Error',
79+
\E_PARSE => 'Parse Error',
80+
\E_ERROR => 'Error',
81+
\E_CORE_ERROR => 'Core Error',
82+
];
83+
6684
// show an error with a full backtrace
6785
$context = (is_null($errfile) ? '' : " at $errfile:$errline");
68-
$e = new Error\Exception('Error ' . $errno . ' - ' . $errstr . $context);
86+
$e = new Error\Exception($levels[$errno] . ' - ' . $errstr . $context);
6987
$e->logError();
7088

7189
// resume normal error processing

0 commit comments

Comments
 (0)