2
Convert warnings to exceptions
6
class MyException extends Exception
8
function __construct($errstr, $errno=0, $errfile='', $errline='')
10
parent::__construct($errstr, $errno);
11
$this->file = $errfile;
12
$this->line = $errline;
16
function Error2Exception($errno, $errstr, $errfile, $errline)
18
throw new MyException($errstr, $errno);//, $errfile, $errline);
21
$err_msg = 'no exception';
22
set_error_handler('Error2Exception');
26
$con = fopen("/tmp/a_file_that_does_not_exist",'r');
30
$trace = $e->getTrace();
31
var_dump($trace[0]['function']);
32
var_dump($trace[1]['function']);
39
string(15) "Error2Exception"
2
Convert warnings to exceptions
6
class MyException extends Exception
8
function __construct($errstr, $errno=0, $errfile='', $errline='')
10
parent::__construct($errstr, $errno);
11
$this->file = $errfile;
12
$this->line = $errline;
16
function Error2Exception($errno, $errstr, $errfile, $errline)
18
throw new MyException($errstr, $errno);//, $errfile, $errline);
21
$err_msg = 'no exception';
22
set_error_handler('Error2Exception');
26
$con = fopen("/tmp/a_file_that_does_not_exist",'r');
30
$trace = $e->getTrace();
31
var_dump($trace[0]['function']);
32
var_dump($trace[1]['function']);
39
string(15) "Error2Exception"