protected function presentExceptionStackTrace(Exception $exception)
{
$phpspecPath = dirname(dirname(__DIR__));
$runnerPath = $phpspecPath . DIRECTORY_SEPARATOR . 'Runner';
$offset = 0;
$text = "\n";
$text .= $this->presentExceptionTraceHeader(sprintf("%2d %s:%d", $offset++, str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $exception->getFile()), $exception->getLine()));
$text .= $this->presentExceptionTraceFunction('throw new ' . get_class($exception), array($exception->getMessage()));
foreach ($exception->getTrace() as $call) {
// skip internal framework calls
if (isset($call['file']) && false !== strpos($call['file'], $runnerPath)) {
break;
}
if (isset($call['file']) && 0 === strpos($call['file'], $phpspecPath)) {
continue;
}
if (isset($call['class']) && 0 === strpos($call['class'], "PHPSpec2\\")) {
continue;
}
if (isset($call['file'])) {
$text .= $this->presentExceptionTraceHeader(sprintf("%2d %s:%d", $offset++, str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $call['file']), $call['line']));
} else {
$text .= $this->presentExceptionTraceHeader(sprintf("%2d [internal]", $offset++));
}
if (isset($call['class'])) {
$text .= $this->presentExceptionTraceMethod($call['class'], $call['type'], $call['function'], $call['args']);
} elseif (isset($call['function'])) {
$args = array_map(array($this, 'presentValue'), $call['args']);
$text .= $this->presentExceptionTraceFunction($call['function'], $call['args']);
}
}
return $text;
}