예제 #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);
 }
예제 #2
0
파일: Exception.php 프로젝트: tany/php-note
 public static function catch($e)
 {
     while (ob_get_level()) {
         $buf = ob_get_clean();
     }
     if (is_int($e)) {
         $args = func_get_args();
         $e = new \ErrorException($args[1], $args[0], 1, $args[2], $args[3]);
     }
     $type = self::$codes[$e->getCode()] ?? '';
     $title = "{$type}: " . self::message($e);
     $file = $e->getFile();
     $line = $e->getLine();
     $trace = $e->getTrace();
     if (preg_match('/view\\/Engine.* eval/', $file)) {
         $idx = $trace[0]['function'] === 'eval' ? 1 : 0;
         $file = $trace[$idx]['args'][2];
         $code = self::preview($trace[$idx]['args'][0], $line);
     } elseif (is_file($file)) {
         $code = self::preview(file_get_contents($file), $line);
     }
     $trace = self::trace($e);
     include 'exception/template.php';
     exit;
 }
예제 #3
0
파일: ConsoleApp.php 프로젝트: cawaphp/cawa
 /**
  * @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());
 }
예제 #5
0
파일: errors.php 프로젝트: shgysk8zer0/core
 /**
  * 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()]);
 }
 /**
  * {@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);
 }
예제 #8
0
파일: Broker.php 프로젝트: hillstill/sooh
 /**
  * 检查是否是指定的数据库错误类型
  * @param \ErrorException $e
  * @param string $type default is duplicateKey
  * @return boolean 
  */
 public static function errorIs($e, $type = \Sooh\DB\Error::duplicateKey)
 {
     $n = $e->getCode() - 0;
     return is_a($e, '\\Sooh\\DB\\Error') && ($n & $type) > 0;
 }
예제 #9
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());
 }