forked from aizuyan/phplog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myexception.php
43 lines (41 loc) · 966 Bytes
/
myexception.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
<?php
/**
* 异常处理类
* @author 燕睿涛
* @email [email protected]
*/
class Myexception extends Exception{
/**
* @desc 异常处理函数
* @parm object $e 异常对象
*/
public static function exceptionHandler($e){
$file = $e->getFile();
$line = $e->getLine();
$code = $e->getCode();
$message= $e->getMessage();
if(Testlog::$log != null){
if(class_exists('Log',false)){
Log::$writeOnAdd = true;
Testlog::$log->add(3,'['.$code.']:'.$message,array('file'=>$file,'line'=>$line));
}
}
}
/**
* @desc 错误处理函数
*
*/
public static function errorHandler($errno,$errstr,$errfile,$errline){
self::exceptionHandler(new ErrorException($errstr,$errno,0,$errfile,$errline));
}
/**
*
*
*/
public static function shutdownHandler(){
$error = error_get_last();
if($error){
self::exceptionHandler(new ErrorException($error['message'],$error['type'],0,$error['file'],$error['line']));
}
}
}