Browse Source

Pass through file name and line number fron PHP7ErrorException up to ExceptionRenderer / _serialize()

inoas 9 years ago
parent
commit
057dfa44b6
2 changed files with 9 additions and 3 deletions
  1. 4 0
      src/Error/ExceptionRenderer.php
  2. 5 3
      src/Error/PHP7ErrorException.php

+ 4 - 0
src/Error/ExceptionRenderer.php

@@ -186,6 +186,10 @@ class ExceptionRenderer implements ExceptionRendererInterface
                 'format' => 'array',
                 'args' => false
             ]);
+            $viewVars['file'] = $exception->getFile();
+            $viewVars['line'] = $exception->getLine();
+            $viewVars['_serialize'][] = 'file';
+            $viewVars['_serialize'][] = 'line';
         }
         $this->controller->set($viewVars);
 

+ 5 - 3
src/Error/PHP7ErrorException.php

@@ -37,9 +37,11 @@ class PHP7ErrorException extends Exception
     public function __construct($error)
     {
         $this->_error = $error;
-        $message = $error->getMessage();
-        $code = $error->getCode();
-        parent::__construct(sprintf('(%s) - %s', get_class($error), $message), $code);
+        $this->message = $error->getMessage();
+        $this->code = $error->getCode();
+        $this->file = $error->getLine();
+        $this->file = $error->getFile();
+        parent::__construct(sprintf('(%s) - %s in %s on %s', get_class($error), $this->message, $this->file, $this->line), $code);
     }
 
     /**