当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorException类代码示例

本文整理汇总了PHP中ErrorException的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException类的具体用法?PHP ErrorException怎么用?PHP ErrorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ErrorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catch

 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;
 }
开发者ID:tany,项目名称:php-note,代码行数:25,代码来源:Exception.php

示例2: handleErrorException

 /**
  * @param \ErrorException $exception
  *
  * @return bool
  */
 protected function handleErrorException(\ErrorException $exception)
 {
     switch ($exception->getSeverity()) {
         case E_ERROR:
         case E_RECOVERABLE_ERROR:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
         case E_PARSE:
             $this->logger->error($this->buildLogMessage($exception));
             break;
         case E_WARNING:
         case E_USER_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
             $this->logger->warning($this->buildLogMessage($exception));
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
             $this->logger->notice($this->buildLogMessage($exception));
             break;
         case E_STRICT:
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
             $this->logger->info($this->buildLogMessage($exception));
             break;
     }
     return true;
 }
开发者ID:phprest,项目名称:phprest,代码行数:34,代码来源:Log.php

示例3: it_alllows_errors_to_be_arrays

 /** @test */
 public function it_alllows_errors_to_be_arrays()
 {
     $errors = [['message' => 'Error', 'path' => '/foo']];
     $exception = new ErrorException($errors, 'Error', 100);
     $this->assertSame(400, $exception->getStatusCode());
     $this->assertJsonStringEqualsJsonString(json_encode(['message' => 'Error', 'logref' => 100, '_embedded' => ['errors' => [['message' => 'Error', 'path' => '/foo']]]]), $exception->getHal()->asJson());
 }
开发者ID:jsor,项目名称:stack-hal,代码行数:8,代码来源:ErrorExceptionTest.php

示例4: handleErrors

 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;
 }
开发者ID:schpill,项目名称:standalone,代码行数:9,代码来源:JsonFormatter.php

示例5: handleErrors

 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);
 }
开发者ID:bafs,项目名称:booboo,代码行数:9,代码来源:HtmlPrettyFormatter.php

示例6: handle

 static function handle($code, $message, $file, $line, $context)
 {
     echo "\n" . static::$codeMap[$code] . ': ' . $message . "\n";
     echo "#0 " . $file . '(' . $line . ")\n";
     $exception = new ErrorException('', $code, 0, $file, $line);
     $trace = $exception->getTraceAsString();
     $trace = preg_replace('~^.*?\\n|\\n.*?$~', '', $trace);
     echo $trace . "\n";
     return true;
 }
开发者ID:nin-jin,项目名称:hyoo.ru,代码行数:10,代码来源:so_error.php

示例7: handleErrors

 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);
 }
开发者ID:schpill,项目名称:standalone,代码行数:10,代码来源:HtmlTableFormatter.php

示例8: handleErrors

 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;
 }
开发者ID:schpill,项目名称:standalone,代码行数:14,代码来源:CommandLineFormatter.php

示例9: shutdownCheck

 public static function shutdownCheck()
 {
     //error_log("shutdown check");
     if ($error = error_get_last()) {
         if ($error['type'] == E_COMPILE_ERROR) {
             $exception = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
             if (strpos($exception->getMessage(), "Cannot redeclare class") !== false) {
                 //send email alerts for duplicate class declarations.. error already logged by php
                 $ErrorHandler = new ErrorHandler($exception);
                 $ErrorHandler->email_alert();
             }
         }
     }
     return;
 }
开发者ID:htmlgraphic,项目名称:HTMLgraphic-MVC,代码行数:15,代码来源:ErrorHandler.class.inc.php

示例10: append

 public function append($k, $v = null, $ifRealAppend = 'throwError')
 {
     if ($this->dbClass == null) {
         throw new \ErrorException('thisWhere ended already');
     }
     if ($ifRealAppend === false) {
         return $this;
     }
     $bakTb = $this->dbClass->_tmpObj($this->forTable);
     if (empty($v) && is_array($v)) {
         if ($ifRealAppend === 'markEmptyArray') {
             $this->_emptyWhere[] = $k;
             return $this;
         } else {
             $err = new \ErrorException('empty Array was Found when build where');
             error_log($err->getMessage() . "\n" . $err->getTraceAsString());
             throw $err;
         }
     }
     if (is_array($k)) {
         foreach ($k as $i => $v) {
             if (is_numeric($i)) {
                 $this->append(null, $v);
             } else {
                 $this->append($i, $v);
             }
         }
     } elseif (is_null($k)) {
         if (is_scalar($v)) {
             $err = new \ErrorException();
             error_log("should avoid:where->append(null,'sql-statement')\n" . $err->getTraceAsString());
             $this->r[] = $v;
         } else {
             $tmp = trim($v->end());
             if (!empty($tmp)) {
                 $tmp = '(' . substr($tmp, 6) . ')';
             }
             $this->r[] = $tmp;
         }
     } else {
         $this->r[] = $this->conv($k, $v);
     }
     $this->dbClass->_tmpObj($bakTb);
     return $this;
 }
开发者ID:hillstill,项目名称:sooh,代码行数:45,代码来源:Where.php

示例11: __construct

 /**
  * @param string $message
  * @param int|string $http_status
  * @param null $filename
  * @param null $lineno
  * @param \Exception $previous
  */
 public function __construct($message = '', $http_status = Response::STATUS_ERROR, $filename = null, $lineno = null, \Exception $previous = null)
 {
     $code = 0;
     $this->status = $http_status;
     switch ($this->status) {
         case Response::STATUS_BAD_REQUEST:
             $code = 1;
             break;
         case Response::STATUS_METHOD_NOT_ALLOWED:
             $code = 2;
             break;
         case Response::STATUS_ERROR:
             $code = 3;
             break;
     }
     $info = array();
     if (!empty($previous)) {
         $info[] = 'caught ' . get_class($previous);
     }
     if (!empty($filename)) {
         $info[] = 'in ' . $filename;
     }
     if (!empty($lineno)) {
         $info[] = 'at line ' . $lineno;
     }
     if (!empty($info)) {
         $this->full_message = $message . ' [' . join(' ', $info) . ']';
     } else {
         $this->full_message = $message;
     }
     parent::__construct($message, $code, 1, is_null($filename) ? __FILE__ : $filename, is_null($lineno) ? __LINE__ : $lineno, $previous);
 }
开发者ID:markdown-extended,项目名称:mde-service,代码行数:39,代码来源:Error.php

示例12: __construct

 /**
  * Constructor
  *
  * @param string  The exception message
  * @param integer The exception code
  */
 public function __construct($message, $code, $severity, $filename, $lineno)
 {
     if (!$message) {
         throw new $this('Unknown ' . get_class($this));
     }
     parent::__construct($message, $code, $severity, $filename, $lineno);
 }
开发者ID:ravenlife,项目名称:Ninja-Framework,代码行数:13,代码来源:error.php

示例13: __construct

 /**
  * 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')) {
         $phpCompatibleTrace = [];
         $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'];
             }
             $phpCompatibleTrace[] = $frame;
         }
         $ref = new \ReflectionProperty('Exception', 'trace');
         $ref->setAccessible(true);
         $ref->setValue($this, $phpCompatibleTrace);
     }
 }
开发者ID:bixuehujin,项目名称:blink,代码行数:37,代码来源:ErrorException.php

示例14: __construct

 public function __construct($required, $code = 0, $previous = null)
 {
     if (is_string($required)) {
         $required = array($required);
     }
     parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code, $previous);
 }
开发者ID:alnutile,项目名称:saucelabs_client,代码行数:7,代码来源:MissingArgumentException.php

示例15: __construct

 /**
  * Constructor.
  *
  * @param string     $message  The Exception message to throw.
  * @param int        $code     The Exception code.
  * @param int        $severity The severity level of the exception.
  * @param string     $filename The filename where the exception is thrown.
  * @param int        $line     The line number where the exception is thrown.
  * @param \Exception $prev     The previous exception --- used for exception chaining.
  *
  * @throws ParseException Exception thrown with default message if none passed.
  */
 public function __construct(string $message = '', int $code = 0, int $severity = 1, string $filename = __FILE__, int $line = __LINE__, \Exception $prev = null)
 {
     if (!$message) {
         throw new $this('Unknown ' . get_class($this));
     }
     parent::__construct($message, $code, $severity, $filename, $line, $prev);
 }
开发者ID:adamblake,项目名称:parse,代码行数:19,代码来源:ParseException.php


注:本文中的ErrorException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。