diff options
author | Simon Rettberg | 2018-02-13 16:26:31 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-02-13 16:26:31 +0100 |
commit | afdedd1b184692b1aacde4d81c2b1b1fb0726c15 (patch) | |
tree | 40974693bc3fb15ed338108d550e7866eee49d94 /index.php | |
parent | [translation] Fix saving language tags containing dots (diff) | |
download | slx-admin-afdedd1b184692b1aacde4d81c2b1b1fb0726c15.tar.gz slx-admin-afdedd1b184692b1aacde4d81c2b1b1fb0726c15.tar.xz slx-admin-afdedd1b184692b1aacde4d81c2b1b1fb0726c15.zip |
index.php: Hacky way of telling the php error handler to skip stack frames
This can be used to show more meaningful error messages in debug mode at
the bottom of the page. Prefix the error message with [skip:N] where
N is the number of stack frames to skip when printing the error message.
The php error log will still receive the complete stack trace.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -104,6 +104,15 @@ spl_autoload_register(function ($class) { if (defined('CONFIG_DEBUG') && CONFIG_DEBUG) { set_error_handler(function ($errno, $errstr, $errfile, $errline) { + if (preg_match('/^\[skip:\s*(\d+)\]\s*(.*)/is', $errstr, $out)) { + $errstr = $out[2]; + $trace = debug_backtrace(); + $idx = (int)$out[1] + 1; + if (count($trace) > $idx) { + $errfile = $trace[$idx]['file']; + $errline = $trace[$idx]['line']; + } + } global $SLX_ERRORS; $SLX_ERRORS[] = array( 'errno' => $errno, |