Paginator now have a default module to show and a settings-file.
[AOOS.git] / AOOSException.php
blob02529e99fd07760cd57b18fc711b239a18823171
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;
20 $this->_name = $name;
21 $this->_msg = $msg;
22 if ($doTrace)
24 $this->_trace = debug_backtrace();
26 if ($code > 2 || $code < 0)
28 throw new AOOSException($core, $core->tr("exception_code_error"));
29 return false;
31 $this->_ecode = $code;
32 $this->core()->setException($this);
35 public function __toString()
37 $str = "<strong>";
38 switch($this->_ecode)
40 case(0):
41 $str .= "fatal_error";
42 break;
43 case(1):
44 $str .= "error";
45 break;
46 case(2):
47 $str .= "warning";
48 break;
50 $str .= "</strong>: ".$this->_name."<br /><div style='font-size: 10pt;'>".$this->_msg."</div><br /><div style='font-size: 10pt; color: #aaa'>";
51 foreach ($this->_trace as $row)
53 if (isset($row["class"]))
55 if ($row["class"] == "AOOSException")
57 continue;
59 $str .= "<strong>".$row["class"]."->".$row["function"]."</strong> in ".$row["file"]." on line ".$row["line"]."<br />";
62 $str .= "</div>";
63 return $str;
66 public function getName() { return $this->_name; }
67 public function getMsg() { return $this->_msg; }
68 public function getEcode() { return $this->_ecode; }
69 public function core() { return $this->_core; }