summaryrefslogtreecommitdiff
path: root/framework/Exceptions
diff options
context:
space:
mode:
authorxue <>2006-03-24 23:06:31 +0000
committerxue <>2006-03-24 23:06:31 +0000
commit8df1407a11df3e5a8c33c6fae1c522707aefccf3 (patch)
treed65fbc70a3c0f22e188f26d413fc7a52f22edb23 /framework/Exceptions
parentc8494fb1d1b8e5e6d2c135d8a8d8777442dae306 (diff)
Enhanced error context display when a PHP error occurs.
Diffstat (limited to 'framework/Exceptions')
-rw-r--r--framework/Exceptions/TErrorHandler.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php
index 23644fb7..4b42491e 100644
--- a/framework/Exceptions/TErrorHandler.php
+++ b/framework/Exceptions/TErrorHandler.php
@@ -207,8 +207,21 @@ class TErrorHandler extends TModule
*/
protected function displayException($exception)
{
- $lines=file($exception->getFile());
+ $fileName=$exception->getFile();
$errorLine=$exception->getLine();
+ if($exception instanceof TPhpErrorException)
+ {
+ // if PHP exception, we want to show the 2nd stack level context
+ // because the 1st stack level is of little use (it's in error handler)
+ $trace=$exception->getTrace();
+ if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line']))
+ {
+ $fileName=$trace[0]['file'];
+ $errorLine=$trace[0]['line'];
+ }
+ }
+ $lines=file($fileName);
+
$beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0;
$endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines);
@@ -227,7 +240,7 @@ class TErrorHandler extends TModule
$tokens=array(
'%%ErrorType%%' => get_class($exception),
'%%ErrorMessage%%' => htmlspecialchars($exception->getMessage()),
- '%%SourceFile%%' => htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')',
+ '%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')',
'%%SourceCode%%' => $source,
'%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()),
'%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),