summaryrefslogtreecommitdiff
path: root/framework
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
parentc8494fb1d1b8e5e6d2c135d8a8d8777442dae306 (diff)
Enhanced error context display when a PHP error occurs.
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/TDataFieldAccessor.php2
-rw-r--r--framework/Exceptions/TErrorHandler.php17
2 files changed, 16 insertions, 3 deletions
diff --git a/framework/Data/TDataFieldAccessor.php b/framework/Data/TDataFieldAccessor.php
index a28b9d1f..aa6d7be7 100644
--- a/framework/Data/TDataFieldAccessor.php
+++ b/framework/Data/TDataFieldAccessor.php
@@ -78,7 +78,7 @@ class TDataFieldAccessor
{
if(is_array($data) || ($data instanceof ArrayAccess))
{
- if(isset($data[$field]))
+ if(isset($data[$field]) || $data[$field]===null)
return $data[$field];
else
throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field);
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(),