forked from tlhunter/sleekmvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Error.php
53 lines (50 loc) · 1.39 KB
/
Error.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
<?php
namespace Sleek;
/**
* Class for dispatching the error handler in the application code
*/
class Error {
/**
* Attempts to handle errors using action_500
* @static
* @param $errno
* @param $errstr
* @param $errfile
* @param $errline
* @param $errcontext
* @return void
*/
public static function handler($errno, $errstr, $errfile, $errline, $errcontext) {
$errorClassName = Core::CONTROLLER_PREFIX . Config::get('error_controller');
/**
* @var $errorClass \App\Controller_Error
*/
$errorClass = new $errorClassName;
$errorClass->action_500($errno, $errstr, $errfile, $errline, $errcontext);
exit();
}
/**
* Attempts to catch fatal errors using action_fatal
* @static
* @return void
*/
public static function shutdown() {
$error = error_get_last();
if ($error['type'] == 1) {
$errorClassName = Core::CONTROLLER_PREFIX . Config::get('error_controller');
/**
* @var $errorClass \App\Controller_Error
*/
$errorClass = new $errorClassName;
$errorClass->action_fatal($error);
}
}
/**
* Registers the error handler
* @static
* @return void
*/
public static function register() {
set_error_handler(array('\\Sleek\\Error', 'handler'));
}
}