Skip to content
Browse files

Added support for nested exceptions (#470, #471)

Requires PHP 5.3
  • Loading branch information...
1 parent 16b1b90 commit e9801e52bd61c07fece49303c5df0cd5dc87a6f7 @psemuu psemuu committed
View
15 PHPUnit/Framework/Error.php
@@ -60,18 +60,17 @@ class PHPUnit_Framework_Error extends Exception
/**
* Constructor.
*
- * @param string $message
- * @param integer $code
- * @param string $file
- * @param integer $line
- * @param array $trace
+ * @param string $message
+ * @param integer $code
+ * @param string $file
+ * @param integer $line
+ * @param Exception $previous
*/
- public function __construct($message, $code, $file, $line, $trace)
+ public function __construct($message, $code, $file, $line, Exception $previous = NULL)
{
- parent::__construct($message, $code);
+ parent::__construct($message, $code, $previous);
$this->file = $file;
$this->line = $line;
- $this->trace = $trace;
}
}
View
4 PHPUnit/Framework/ExpectationFailedException.php
@@ -66,11 +66,11 @@ class PHPUnit_Framework_ExpectationFailedException extends PHPUnit_Framework_Ass
*/
protected $comparisonFailure;
- public function __construct($message, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
+ public function __construct($message, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL, Exception $previous = NULL)
{
$this->comparisonFailure = $comparisonFailure;
- parent::__construct($message);
+ parent::__construct($message, 0, $previous);
}
/**
View
2 PHPUnit/Util/ErrorHandler.php
@@ -128,6 +128,6 @@ public static function handleError($errno, $errstr, $errfile, $errline)
$exception = 'PHPUnit_Framework_Error';
}
- throw new $exception($errstr, $errno, $errfile, $errline, $trace);
+ throw new $exception($errstr, $errno, $errfile, $errline);
}
}
View
6 PHPUnit/Util/Filter.php
@@ -83,7 +83,11 @@ public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
$eFile = $e->getSyntheticFile();
$eLine = $e->getSyntheticLine();
} else {
- $eTrace = $e->getTrace();
+ if ($e->getPrevious()) {
+ $eTrace = $e->getPrevious()->getTrace();
+ } else {
+ $eTrace = $e->getTrace();
+ }
$eFile = $e->getFile();
$eLine = $e->getLine();
}

0 comments on commit e9801e5

Please sign in to comment.
Something went wrong with that request. Please try again.