10 defined(
'JPATH_PLATFORM') or die;
26 protected $level = null;
32 protected $code = null;
38 protected $message = null;
55 protected $file = null;
71 protected $function = null;
79 protected $class = null;
85 protected $type = null;
93 protected $args = array();
99 protected $backtrace = null;
115 public function __construct($msg, $code = 0, $level = null, $info = null, $backtrace =
false)
119 $this->level = $level;
121 $this->message = $msg;
128 if ($backtrace && function_exists(
'debug_backtrace'))
130 $this->backtrace = debug_backtrace();
132 for ($i = count($this->backtrace) - 1; $i >= 0; --$i)
135 if (isset($this->backtrace[$i][
'file']))
137 $this->file = $this->backtrace[$i][
'file'];
139 if (isset($this->backtrace[$i][
'line']))
141 $this->line = $this->backtrace[$i][
'line'];
143 if (isset($this->backtrace[$i][
'class']))
145 $this->
class = $this->backtrace[$i]['class'];
147 if (isset($this->backtrace[$i][
'function']))
149 $this->
function = $this->backtrace[$i][
'function'];
151 if (isset($this->backtrace[$i][
'type']))
153 $this->type = $this->backtrace[$i][
'type'];
157 if (isset($this->backtrace[$i][
'args']))
159 $this->args = $this->backtrace[$i][
'args'];
168 parent::__construct($msg, (
int) $code);
180 public function __toString()
184 return $this->message;
195 public function toString()
199 return (
string) $this;
214 public function get($property, $default = null)
218 if (isset($this->$property))
220 return $this->$property;
236 public function getProperties($public =
true)
240 $vars = get_object_vars($this);
243 foreach ($vars as $key => $value)
245 if (
'_' == substr($key, 0, 1))
266 public function getError($i = null, $toString =
true)
274 $error = end($this->_errors);
276 elseif (!array_key_exists($i, $this->_errors))
283 $error = $this->_errors[$i];
287 if ($error instanceof Exception && $toString)
289 return (
string) $error;
304 public function getErrors()
308 return $this->_errors;
323 public function set($property, $value = null)
327 $previous = isset($this->$property) ? $this->$property : null;
328 $this->$property = $value;
343 public function setProperties($properties)
348 $properties = (array) $properties;
350 if (is_array($properties))
352 foreach ($properties as $k => $v)
374 public function setError($error)
378 array_push($this->_errors, $error);