protected function displayException($exception)
{
if (php_sapi_name() === 'cli') {
echo $exception->getMessage() . "\n";
echo $exception->getTraceAsString();
return;
}
if ($exception instanceof TTemplateException) {
$fileName = $exception->getTemplateFile();
$lines = empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName);
$source = $this->getSourceCode($lines, $exception->getLineNumber());
if ($fileName === '') {
$fileName = '---embedded template---';
}
$errorLine = $exception->getLineNumber();
} else {
if (($trace = $this->getExactTrace($exception)) !== null) {
$fileName = $trace['file'];
$errorLine = $trace['line'];
} else {
$fileName = $exception->getFile();
$errorLine = $exception->getLine();
}
$source = $this->getSourceCode(@file($fileName), $errorLine);
}
if ($this->getApplication()->getMode() === TApplicationMode::Debug) {
$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado4">PRADO</a>/' . Prado::getVersion();
} else {
$version = '';
}
$tokens = array('%%ErrorType%%' => get_class($exception), '%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())), '%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')', '%%SourceCode%%' => $source, '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), '%%Version%%' => $version, '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()));
$content = $this->getExceptionTemplate($exception);
echo strtr($content, $tokens);
}