Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Printing cause of exception when present

  • Loading branch information...
commit 62981419cadfaf8d7d51c3c225ecf148824bc7f5 1 parent 023b0fc
@matheusd matheusd authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 PHPUnit/TextUI/ResultPrinter.php
View
14 PHPUnit/TextUI/ResultPrinter.php
@@ -274,6 +274,20 @@ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
$defect->thrownException()
)
);
+
+ $e = $defect->thrownException();
+ if (method_exists($e, 'getPrevious')) {
+ //php >= 5.3, exceptions may have a previous cause
+ $e = $e->getPrevious();
+ while ($e) {
+ $this->write(
+ "\nCaused by\n" .
+ PHPUnit_Util_Filter::getFilteredStacktrace($e)
+ );
+ $e = $e->getPrevious();
+ }
+ }
+
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.