Example #1
0
 /**
  * Returns a description for an exception.
  *
  * @param  Exception $e
  * @return string
  * @since  Method available since Release 3.2.0
  */
 public static function exceptionToString(Exception $e)
 {
     if ($e instanceof PHPUnit_Framework_SelfDescribing) {
         $buffer = $e->toString();
         if ($e instanceof PHPUnit_Framework_ComparisonFailure) {
             $buffer = trim($buffer . "\n" . $e->getDiff());
         }
         if ($e instanceof PHPUnit_Framework_ExpectationFailedException && $e->getComparisonFailure()) {
             $buffer = trim($buffer . "\n" . $e->getComparisonFailure()->getDiff());
         }
         if (!empty($buffer)) {
             $buffer .= "\n";
         }
     } else {
         if ($e instanceof PHPUnit_Framework_Error) {
             $buffer = $e->getMessage() . "\n";
         } else {
             $buffer = get_class($e) . ': ' . $e->getMessage() . "\n";
         }
     }
     return $buffer;
 }