Beispiel #1
2
 public function handleErrorException(\ErrorException $exception)
 {
     $message = sprintf('%s: %s in %s:%d', $this->errorCodeName($exception->getCode()), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     $exception_trace = $exception->getTraceAsString();
     $exception_trace = substr($exception_trace, strpos($exception_trace, PHP_EOL) + 1);
     $message .= PHP_EOL . $exception_trace;
     $this->save($message);
 }
Beispiel #2
0
 public function handleErrors(\ErrorException $e)
 {
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $type = 'Error (' . $severity . ')';
     $message = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     return $this->getHtml($type, $message, $file, $line);
 }
Beispiel #3
0
 public function handleErrors(\ErrorException $e)
 {
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $message = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = ['message' => $message, 'severity' => $severity, 'file' => $file, 'line' => $line];
     return $error;
 }
 public function handleErrors(\ErrorException $e)
 {
     $errorString = "<strong>%s</strong>: %s in <strong>%s</strong> on line <strong>%d</strong>";
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $error = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = sprintf($errorString, $severity, $error, $file, $line);
     return $this->getTable($error);
 }
 public function handleErrors(\ErrorException $e)
 {
     $errorString = "%s%s in %s on line %d\n";
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     // Let's calculate the length of the box, and set the box border.
     $dashes = "\n+" . str_repeat('-', strlen($severity) + 2) . "+\n";
     $severity = $dashes . '| ' . strtoupper($severity) . " |" . $dashes;
     // Okay, now let's prep the message components.
     $error = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = sprintf($errorString, $severity, $error, $file, $line);
     return $error;
 }
Beispiel #6
0
 /**
  * @param \Throwable $exception
  */
 public static function exceptionHandler(\Throwable $exception)
 {
     // This error code is not included in error_reporting
     if (!error_reporting() || $exception->getLine() == 0) {
         return;
     }
     $output = new ConsoleOutput(OutputInterface::VERBOSITY_VERY_VERBOSE);
     if (!$exception instanceof \Exception) {
         $exception = new \ErrorException($exception->getMessage(), $exception->getCode(), 0, $exception->getFile(), $exception->getLine(), $exception);
         self::$application->renderException($exception, $output);
     } else {
         self::$application->renderException($exception, $output);
     }
 }
 public function __construct($message, \ErrorException $previous)
 {
     parent::__construct($message, $previous->getCode(), $previous->getSeverity(), $previous->getFile(), $previous->getLine(), $previous->getPrevious());
     $this->setTrace($previous->getTrace());
 }
Beispiel #8
0
 /**
  * Given an error, generates an array in the format
  * generated by ErrorException
  * @param  ErrorException $exception
  * @return array
  */
 protected function getFrameFromError(ErrorException $exception)
 {
     return array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'class' => null, 'args' => array());
 }
Beispiel #9
0
 /**
  * Log error exceptions to user console using JSON_Response::error
  *
  * @param ErrorException $err_exc The error exception
  * @return void
  * @uses JSON_Response
  */
 public function consoleErrorException(\ErrorException $err_exc)
 {
     Core\JSON_Response::load()->error(['message' => $err_exc->getMessage(), 'code' => $err_exc->getCode(), 'severity' => $err_exc->getSeverity(), 'line' => $err_exc->getLine(), 'file' => $err_exc->getFile(), 'trace' => $err_exc->getTrace()]);
 }
Beispiel #10
0
 private static function applyErrorThrowableInfo(ThrowableInfo $throwableInfo, \ErrorException $e)
 {
     if (null !== ($filePath = $e->getFile())) {
         $throwableInfo->addCodeInfo(self::createCodeInfo($filePath, $e->getLine()));
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function onNotSuccessfulTest(\Exception $e)
 {
     if (!in_array(get_class($e), array('PHPUnit_Framework_IncompleteTestError', 'PHPUnit_Framework_SkippedTestError'))) {
         $e = new \ErrorException($e->getMessage() . "\nScreenshot: " . $this->makeScreenshot(), $e->getCode(), 0, $e->getFile(), $e->getLine() - 1, $e);
     }
     parent::onNotSuccessfulTest($e);
 }
 /**
  * @param \ErrorException $exception
  */
 protected function handleFatalError($exception)
 {
     \Rollbar::report_php_error($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     parent::handleException($exception);
 }
Beispiel #13
0
 /**
  * Format an \ErrorException into a string destined for PHP error_log()
  *
  * @access private
  * @param \ErrorException $exception The error exception to format
  * @return string The formatted error message
  */
 function formatErrorException($exception)
 {
     if (!$exception instanceof \ErrorException) {
         return '';
     }
     $errorType = '';
     $errorCode = $exception->getCode();
     // Find an error type based on the error code
     switch ($errorCode) {
         case $errorCode & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR):
             $errorType = 'PHP Fatal error';
             break;
         case $errorCode & (E_NOTICE | E_USER_NOTICE):
             $errorType = 'PHP Notice';
             break;
         case $errorCode & (E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING):
             $errorType = 'PHP Warning';
             break;
         case $errorCode & (E_DEPRECATED | E_USER_DEPRECATED):
             $errorType = 'PHP Deprecated';
             break;
         case $errorCode & E_PARSE:
             $errorType = 'PHP Parse error';
             break;
         case $errorCode & E_STRICT:
             $errorType = 'PHP Strict standards';
             break;
     }
     return formatPHPErrorLog($exception->getMessage(), $errorType, $exception->getFile(), $exception->getLine());
 }
Beispiel #14
0
 public static function shutdown()
 {
     $isError = false;
     if ($error = error_get_last()) {
         switch ($error['type']) {
             case E_ERROR:
                 // 1
             // 1
             case E_CORE_ERROR:
                 // 16
             // 16
             case E_COMPILE_ERROR:
                 // 64
             // 64
             case E_USER_ERROR:
                 //256
             //256
             case E_PARSE:
                 //4
                 $isError = true;
                 break;
             case E_WARNING:
                 //2
             //2
             case E_NOTICE:
                 //8
             //8
             case E_CORE_WARNING:
                 //32
             //32
             case E_COMPILE_WARNING:
                 //128
             //128
             case E_USER_WARNING:
                 //512
             //512
             case E_USER_NOTICE:
                 //1024
             //1024
             case E_STRICT:
                 //2048
                 break;
         }
     }
     if ($isError) {
         http_response_code(500);
         $guid = false;
         try {
             $e = new ErrorException($error['message'], 0, 1, $error['file'], $error['line']);
             //$guid = Dfi_Error_Report::saveException($e);
         } catch (Exception $e) {
             $guid = false;
         }
         if (!preg_match('/cli/', php_sapi_name())) {
             Zend_Registry::get('shutdownLogger')->log($error['message'] . ' : ' . $error['file'] . ' : (' . $error['line'] . ')', Zend_Log::CRIT);
             if (!Dfi_App_Config::get('main.showDebug')) {
                 $url = "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'] . '/';
                 header("Location: " . $url . "error/error" . ($guid ? '/guid/' . $guid : ''));
                 exit;
             } else {
                 ob_clean();
                 echo '<pre>REPORT: ' . ($guid ? $guid : 'brak') . "\n";
                 echo 'REQUEST: ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "\n";
                 echo 'REFERER: ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . "\n";
                 echo 'ERROR: ' . $e->getMessage() . ' : ' . $e->getFile() . ' : (' . $e->getLine() . ')' . "\n" . $e->getTraceAsString() . '</pre>';
             }
         }
     }
 }