本文整理汇总了PHP中ErrorException::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException::getCode方法的具体用法?PHP ErrorException::getCode怎么用?PHP ErrorException::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorException
的用法示例。
在下文中一共展示了ErrorException::getCode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: handleErrorException
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);
}
示例3: exceptionHandler
/**
* @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);
}
}
示例4: __construct
public function __construct($message, \ErrorException $previous)
{
parent::__construct($message, $previous->getCode(), $previous->getSeverity(), $previous->getFile(), $previous->getLine(), $previous->getPrevious());
$this->setTrace($previous->getTrace());
}
示例5: consoleErrorException
/**
* 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()]);
}
示例6: onNotSuccessfulTest
/**
* {@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);
}
示例7: handleFatalError
/**
* @param \ErrorException $exception
*/
protected function handleFatalError($exception)
{
\Rollbar::report_php_error($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
parent::handleException($exception);
}
示例8: errorIs
/**
* 检查是否是指定的数据库错误类型
* @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: formatErrorException
/**
* 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());
}