-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApplicationException.php
More file actions
94 lines (80 loc) · 2.03 KB
/
ApplicationException.php
File metadata and controls
94 lines (80 loc) · 2.03 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* General exception which might be raised within an application context
*
* @package framework
* @author Integry Systems
*/
class ApplicationException extends Exception
{
public static function getFileTrace($trace)
{
$showedFiles = array();
$i = 0;
$traceString = '';
$ajax = false; //isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? true : false;
// Get new line
$newLine = $ajax ? "\n" : "<br />\n";
foreach($trace as $call)
{
if(isset($call['file']) && isset($call['line']) && !isset($showedFiles[$call['file']][$call['line']]))
{
$showedFiles[$call['file']][$call['line']] = true;
// Get file name and line
if($ajax)
{
$position = ($i++).": {$call['file']}:{$call['line']}";
}
else
{
$position = "<strong>".($i++)."</strong>: \"{$call['file']}\":{$call['line']}";
}
// Get function name
if(isset($call['class']) && isset($call['type']) && isset($call['function']))
{
$functionName = "{$call['class']}{$call['type']}{$call['function']}";
}
else
{
$functionName = $call['function'];
}
// Get function arguments
$arguments = '';
$j = 1;
if (isset($call['args']))
{
foreach($call['args'] as $argv)
{
switch(gettype($argv))
{
case 'string':
$arguments .= "\"$argv\"";
break;
case 'boolean':
$arguments .= ($argv ? 'true' : 'false');
break;
case 'integer':
case 'double':
$arguments .= $argv;
break;
case 'object':
$arguments .= "(object)" . get_class($argv);
break;
case 'array':
$arguments .= "Array";
break;
default:
$arguments .= $argv;
break;
}
if($j < count($call['args'])) $arguments .= ", "; $j++;
}
}
// format the output line
$traceString .= "$newLine$position - $functionName($arguments)";
}
}
return $traceString;
}
}
?>