00001 <?php
00002
00006 class spunQ_Exception extends Exception {
00007
00012 protected $backtrace = NULL;
00013
00020 public function __construct($message = NULL) {
00021 if ($message !== NULL) {
00022 parent::__construct($message);
00023 } else {
00024 parent::__construct($this->getExtendedMessage());
00025 }
00026 return NULL;
00027 }
00028
00035 public function getExtendedMessage() {
00036 return $this->getMessage();
00037 }
00038
00045 public function prettyPrint($useHtml = false) {
00046 if ($useHtml) {
00047 $this->prettyPrintHtml();
00048 return;
00049 }
00050 echo "\n\n";
00051 echo '--[ '.get_class($this)." ]--\n";
00052 echo $this->getExtendedMessage();
00053 echo "\n\n";
00054 echo "Backtrace:\n";
00055 $this->printBacktrace(' ');
00056 return $this;
00057 }
00058
00063 public function prettyPrintHtml() {
00064 $string = "\n";
00065 $string .= '--[ '.get_class($this)." ]--\n";
00066 $string .= $this->getExtendedMessage();
00067 $string .= "\n\n";
00068 echo '<span style="color:red">' . nl2br(htmlentities($string, ENT_NOQUOTES, 'UTF-8')) . '</span><pre style="color:blue">';
00069 $string = "Backtrace:\n";
00070 echo htmlentities($string, ENT_NOQUOTES, 'UTF-8');
00071 $this->printBacktrace(' ');
00072 echo '</pre>';
00073 return $this;
00074 }
00075
00082 public function printBacktrace($indent = NULL) {
00083 echo $this->getBacktrace()->toString($indent);
00084 return $this;
00085 }
00086
00091 public function getBacktrace() {
00092 if ($this->backtrace === NULL) {
00093 $this->backtrace = new spunQ_Backtrace(parent::getTrace());
00094 }
00095 return $this->backtrace;
00096 }
00097
00098 }
00099