コード例 #1
0
 /**
  * Constructs the exception.
  *
  * @link http://php.net/manual/en/errorexception.construct.php
  * @param $message [optional]
  * @param $code [optional]
  * @param $severity [optional]
  * @param $filename [optional]
  * @param $lineno [optional]
  * @param $previous [optional]
  */
 public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, \Exception $previous = null)
 {
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
     if (function_exists('xdebug_get_function_stack')) {
         $trace = array_slice(array_reverse(xdebug_get_function_stack()), 3, -1);
         foreach ($trace as &$frame) {
             if (!isset($frame['function'])) {
                 $frame['function'] = 'unknown';
             }
             // XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695
             if (!isset($frame['type']) || $frame['type'] === 'static') {
                 $frame['type'] = '::';
             } elseif ($frame['type'] === 'dynamic') {
                 $frame['type'] = '->';
             }
             // XDebug has a different key name
             if (isset($frame['params']) && !isset($frame['args'])) {
                 $frame['args'] = $frame['params'];
             }
         }
         $ref = new \ReflectionProperty('Exception', 'trace');
         $ref->setAccessible(true);
         $ref->setValue($this, $trace);
     }
 }
コード例 #2
0
 /**
  * Handles fatal PHP errors
  */
 public function handleFatalError()
 {
     unset($this->_memoryReserve);
     // load ErrorException manually here because autoloading them will not work
     // when error occurs while autoloading a class
     if (!class_exists('Leaps\\Base\\ErrorException', false)) {
         require_once __DIR__ . '/ErrorException.php';
     }
     $error = error_get_last();
     if (ErrorException::isFatalError($error)) {
         if (!empty($this->_hhvmException)) {
             $exception = $this->_hhvmException;
         } else {
             $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']);
         }
         $this->exception = $exception;
         $this->logException($exception);
         if ($this->discardExistingOutput) {
             $this->clearOutput();
         }
         $this->renderException($exception);
         // need to explicitly flush logs because exit() next will terminate the app immediately
         Leaps::getLogger()->flush(true);
         if (defined('HHVM_VERSION')) {
             flush();
         }
         exit(1);
     }
 }