-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathException.php
100 lines (89 loc) · 1.73 KB
/
Exception.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
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
95
96
97
98
99
100
<?php
/**
* Google_Exception
* @package Google
* @author Thomas Schaefer
* @copyright Thomas Schaefer
* @since 2009-05-20
*/
/**
* Google_Exception
* @package Google
* @author Thomas Schaefer
* @copyright Thomas Schaefer
* @since 2009-05-20
*/
class Google_Exception extends Exception {
/**
* @var array $parameters
*/
private $parameters = array();
/**
* @var mixed $data
*/
private $data;
/**
* setParameter
* @param string $name
* @param mixed $value
*/
public function setParameter($name, $value) {
$this->parameters[$name] = $value;
}
/**
* getParameter
* @param $string $name
* @return mixed
*/
public function getParameter($name) {
if($this->hasParameter($name)) {
return $this->parameters[$name];
}
return false;
}
/**
* hasParameter
* @param string $name
* @return bool
*/
public function hasParameter($name) {
if(array_key_exists($name, $this->parameters)) {
return true;
}
return false;
}
/**
* templateFile
* @desc returns path to template
* @param string $name
* @var static
* @return string
*/
private static function templateFile($name) {
return dirname(__FILE__).DIRECTORY_SEPARATOR.'Exception'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.$name.".phtml";
}
/**
* template
* @desc renders template
* @param string $name
* @return string
*/
private function template($name=null) {
ob_start();
include_once(self::templateFile(($name?$name:__CLASS__)));
$template = ob_get_contents();
ob_end_clean();
return $template;
}
/**
* show
* @desc prints out exception
* @param string $name
* @param mixed $data
*/
public function show($name=null, $data=null) {
$this->data = $data;
echo $this->template($name);
exit;
}
}