Permalink
Browse files

Start work on 0.2.0:

- Remove getCause as it just calls getPrevious and that's in PHP 5.3 by default
- Remove getUniqueId as it not used anywhere nor what it produces
  • Loading branch information...
1 parent cd02018 commit aba24c61f76c71183879484890bc79f4931de053 @helgi helgi committed Feb 21, 2010
Showing with 13 additions and 22 deletions.
  1. +2 −0 RELEASE-0.2.0
  2. +11 −22 src/Exception.php
View
@@ -0,0 +1,2 @@
+- Remove getCause() as it just uses the built in getPrevious() that was added in PHP 5.3
+- Remove getUniqueId as it's used anywhere
View
@@ -109,7 +109,6 @@
const OBSERVER_TRIGGER = -4;
const OBSERVER_DIE = -8;
private static $_observers = array();
- private static $_uniqueid = 0;
private $_trace;
/**
@@ -139,9 +138,11 @@ public function __construct($message, $p2 = null, $p3 = null)
$code = null;
$cause = null;
}
+
if (!is_string($message)) {
throw new \Exception('exception message must be a string, was ' . gettype($message));
}
+
parent::__construct($message, $code, $cause);
$this->signal();
}
@@ -164,21 +165,14 @@ public static function removeObserver($label = 'default')
unset(self::$_observers[$label]);
}
- /**
- * @return int unique identifier for an observer
- */
- public static function getUniqueId()
- {
- return self::$_uniqueid++;
- }
-
private function signal()
{
foreach (self::$_observers as $func) {
if (is_callable($func)) {
call_user_func($func, $this);
continue;
}
+
settype($func, 'array');
switch ($func[0]) {
case self::OBSERVER_PRINT :
@@ -199,16 +193,6 @@ private function signal()
}
}
- /**
- * Returns the exception that caused this exception to be thrown
- * @access public
- * @return Exception|array The context of the exception
- */
- public function getCause()
- {
- return $this->getPrevious();
- }
-
/**
* Function must be public to call on caused exceptions
* @param array
@@ -220,12 +204,14 @@ public function getCauseMessage(&$causes)
'message' => $this->message,
'file' => 'unknown',
'line' => 'unknown');
+
if (isset($trace[0])) {
if (isset($trace[0]['file'])) {
$cause['file'] = $trace[0]['file'];
$cause['line'] = $trace[0]['line'];
}
}
+
$causes[] = $cause;
if ($this->getPrevious() instanceof self) {
$this->getPrevious()->getCauseMessage($causes);
@@ -249,7 +235,7 @@ public function getCauseMessage(&$causes)
}
public function getTraceSafe()
- {
+ {
if (!isset($this->_trace)) {
$this->_trace = $this->getTrace();
if (empty($this->_trace)) {
@@ -304,6 +290,7 @@ public function toHtml()
if (!empty($v['class'])) {
$html .= $v['class'] . $v['type'];
}
+
$html .= $v['function'];
$args = array();
if (!empty($v['args'])) {
@@ -321,12 +308,14 @@ public function toHtml()
}
}
}
+
$html .= '(' . implode(', ',$args) . ')'
. '</td>'
. '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
. ':' . (isset($v['line']) ? $v['line'] : 'unknown')
. '</td></tr>' . "\n";
}
+
$html .= '<tr><td align="center">' . ($k+1) . '</td>'
. '<td>{main}</td>'
. '<td>&nbsp;</td></tr>' . "\n"
@@ -344,7 +333,7 @@ public function toText()
. $cause['message'] . ' in ' . $cause['file']
. ' on line ' . $cause['line'] . "\n";
}
+
return $causeMsg . $this->getTraceAsString();
}
-}
-?>
+}

0 comments on commit aba24c6

Please sign in to comment.