-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_handler.php
61 lines (57 loc) · 2.08 KB
/
error_handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Scratchpad to quickly try PHP code
*
* See https://github.com/port8000/pad
* Copyright 2012 Port 8000 UG (haftungsbeschraenkt)
* This code is licensed under both the MIT and GPL license.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
ini_set('track_errors', 1);
ini_set('display_errors', 0);
error_reporting(-1);
set_error_handler('___e');
/* catch fatal errors */
register_shutdown_function(function() {
$error = error_get_last();
if ($error && in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR,
E_COMPILE_ERROR))) {
___e($error['type'], $error['message'], $error['file'], $error['line']);
}
});
function ___e($errno, $errstr, $errfile, $errline) {
global $___s;
$___s = False;
if (!defined ('E_RECOVERABLE_ERROR')) { define ('E_RECOVERABLE_ERROR', 4096); }
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Recoverable Error'
);
if (array_key_exists($errno, $errortype)) {
$errtype = $errortype[$errno];
} else {
$errtype = 'Unknown Error';
}
echo '<div class="error">';
printf('<span class="error__type"><em>%s:</em> %s</span>', $errtype, $errstr);
if (in_array($errno, array(E_ERROR, E_PARSE, E_CORE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
echo '<div class="error__backtrace">';
debug_print_backtrace();
echo '</div>';
}
echo '</div>';
}
#EOF