-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.php
More file actions
63 lines (51 loc) · 1.5 KB
/
Debug.php
File metadata and controls
63 lines (51 loc) · 1.5 KB
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
62
63
<?php
/**
* NEOS PHP FRAMEWORK
* @copyright Bill Rocha - http://plus.google.com/+BillRocha
* @license MIT
* @author Bill Rocha - prbr@ymail.com
* @version 0.0.1
* @package NEOS
* @access public
* @since 0.3.0
*
*/
namespace Neos;
class Debug
{
//Error handler function
static function errorHandler($errno, $errstr, $errfile, $errline) {
switch ($errno) {
case E_USER_ERROR:
echo "<b>ERROR:</b> [$errno] $errstr<br>
<b>File: </b>$errfile [$errline]<br>
Aborting...<br>";
exit(1);
break;
case E_USER_WARNING:
echo "<b>WARNING:</b> [$errno] $errstr<br><b>File:</b> $errfile [$errline]";
break;
case E_USER_NOTICE:
echo "<b>NOTICE:</b> [$errno] $errstr<br><b>File:</b> $errfile [$errline]";
break;
default:
echo "<b>Unknown error type:</b> [$errno] $errstr<br><b>File:</b> $errfile [$errline]";
break;
}
/* Don't execute PHP internal error handler */
return true;
}
//Exception function
static function exceptionHandler($e) {
if(get_class($e) == 'PDOException'){
$err = $e->getMessage().'<br>code: '.$e->getCode();
} else {
$err =
'<b>Code:</b>'.$e->getCode().'<br>'.
'<b>Message:</b> <i>'.$e->getMessage().'</i><br>'.
'<b>Thrown in: </b>'.$e->getFile().' ['.$e->getLine().']<br>'.
'<b>Stack trace:</b><pre>'.$e->getTraceAsString().'</pre>';
}
exit($err);
}
}