errException.php
1.2 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
64
65
66
67
<?php
static $oldErrHandler = NULL;
class errException extends Exception
{
protected $errContext;
function __construct ($msg, $no, $file, $line, $context)
{
parent::__construct ($msg, $no);
$this->file = $file;
$this->line = $line;
$this->errContext = $context;
}
function __toString ()
{
$retStr = "Laufzeitfehler (" . $this->code . "): \n";
$retStr .= $this->message . "\n\n";
$retStr .= 'Datei: ' . $this->file . "\n";
$retStr .= 'Zeile: ' . $this->line . "\n";
if ($this->errContext != NULL)
{
$retStr .= "Fehler Context: \n";
$retStr .= print_r ($this->errContext, TRUE) . "\n";
}
$retStr .= "Aufruf Stack: \n";
$retStr .= $this->getTraceAsString () . "\n";
return $retStr;
}
function getErrContext ()
{
return $this->errContext;
}
}
function mapErrToExc ($no, $msg, $file, $line, $con)
{
throw new errException ($msg, $no, $file, $line, $con);
}
function setErrExceptionMapping ()
{
global $oldErrHandler;
if ($oldErrHandler == NULL)
$oldErrHandler = set_error_handler ('mapErrToExc');
}
function resetErrExceptionMapping ()
{
global $oldErrHandler;
if ($oldErrHandler != NULL)
{
set_error_handler ($oldErrHandler);
$oldErrHandler = NULL;
}
}
?>