Implemented AOOSModel
[AOOS.git] / AOOSException.php
blob77344b3adafff66d8ca07c0d1e12fda152a0d0c9
1 <?php
3 /**
4 * AOOSException
5 * @author Sebastian Skejø
6 */
8 class AOOSException extends Exception
10 private $_core = null;
11 private $_name = null;
12 private $_msg = null;
13 private $_trace = null;
14 private $_ecode = null;
16 public function __construct($core, $name, $msg="", $doTrace=true, $code = 0)
18 $this->_core = $core;
19 $this->_name = $name;
20 $this->_msg = $msg;
21 if ($doTrace)
23 $this->_trace = debug_backtrace();
25 if ($code > 2 || $code < 0)
27 throw new AOOSException($core, $core->tr("exception_code_error"));
28 return false;
30 $this->_ecode = $code;
31 $this->_core->setException($this);
34 public function __toString()
36 $str = "<strong>";
37 switch($this->_ecode)
39 case(0):
40 $str .= "fatal_error";
41 break;
42 case(1):
43 $str .= "error";
44 break;
45 case(2):
46 $str .= "warning";
47 break;
49 $str .= "</strong>: ".$this->_name."<br />".$this->_msg."<br /><br />";
50 foreach ($this->_trace as $row)
52 if (isset($row["class"]))
54 if ($row["class"] == "AOOSException")
56 continue;
58 $str .= "<strong>".$row["class"]."->".$row["function"]."</strong> in ".$row["file"]." on line ".$row["line"];
61 return $str;
64 public function getName() { return $this->_name; }
65 public function getMsg() { return $this->_msg; }
66 public function getEcode() { return $this->_ecode; }
67 /* public function getTrace() { return $this->_trace; }*/