本文整理汇总了PHP中ErrorException类的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException类的具体用法?PHP ErrorException怎么用?PHP ErrorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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);
}
开发者ID:buglloc,项目名称:php-fatal-handler,代码行数:8,代码来源:handler.php
示例12: handleWrite
public function handleWrite()
{
$error = null;
set_error_handler(function ($errno, $errstr, $errfile, $errline) use(&$error) {
$error = array('message' => $errstr, 'number' => $errno, 'file' => $errfile, 'line' => $errline);
});
$sent = fwrite($this->stream, $this->data);
restore_error_handler();
// Only report errors if *nothing* could be sent.
// Any hard (permanent) error will fail to send any data at all.
// Sending excessive amounts of data will only flush *some* data and then
// report a temporary error (EAGAIN) which we do not raise here in order
// to keep the stream open for further tries to write.
// Should this turn out to be a permanent error later, it will eventually
// send *nothing* and we can detect this.
if ($sent === 0 || $sent === false) {
if ($error === null) {
$error = new \RuntimeException('Send failed');
} else {
$error = new \ErrorException($error['message'], 0, $error['number'], $error['file'], $error['line']);
}
$this->emit('error', array(new \RuntimeException('Unable to write to stream: ' . $error->getMessage(), 0, $error), $this));
return;
}
$exceeded = isset($this->data[$this->softLimit - 1]);
$this->data = (string) substr($this->data, $sent);
// buffer has been above limit and is now below limit
if ($exceeded && !isset($this->data[$this->softLimit - 1])) {
$this->emit('drain', array($this));
}
// buffer is now completely empty (and not closed already)
if ($this->data === '' && $this->listening) {
$this->loop->removeWriteStream($this->stream);
$this->listening = false;
$this->emit('full-drain', array($this));
}
}
开发者ID:reactphp,项目名称:stream,代码行数:37,代码来源:Buffer.php
示例13: __construct
public function __construct(\Throwable $e)
{
if ($e instanceof \ParseError) {
$message = 'Parse error: ' . $e->getMessage();
$severity = E_PARSE;
} elseif ($e instanceof \TypeError) {
$message = 'Type error: ' . $e->getMessage();
$severity = E_RECOVERABLE_ERROR;
} else {
$message = $e->getMessage();
$severity = E_ERROR;
}
\ErrorException::__construct($message, $e->getCode(), $severity, $e->getFile(), $e->getLine());
$this->setTrace($e->getTrace());
}
开发者ID:zanderbaldwin,项目名称:symfony,代码行数:15,代码来源:FatalThrowableError.php
示例14: __construct
/**
* constructor method which always needs to be called to stack errors for error
* output dumping/logging and call the parent constructor to set all error arguments
* because only parent constructor of phps native Exception class can set instance
* properties. the class constructor expects the same arguments as its parent or instead
* of passing a message string in first parameter can be called with an instance of
* exception. in this case the arguments of passed instances are compared with the
* constructor arguments to determine which will be passed to parent constructor.
* the instance will be passed
*
* @error 10501
* @param string|object $mixed expects any of the above described values (string or instance of Exception)
* @param int $code expects optional error code
* @param int $severity expects optional severity level
* @param null|string $file expects the file name where exception was created
* @param null|int $line expects the line where exception was created
*/
public function __construct($mixed = "", $code = 0, $severity = XAPP_ERROR_ERROR, $file = null, $line = null)
{
if (is_object($mixed)) {
if ($mixed instanceof ErrorException) {
$severity = (int) $severity > (int) $mixed->getSeverity() ? (int) $severity : (int) $mixed->getSeverity();
}
parent::__construct($mixed->getMessage(), (int) $code > (int) $mixed->getCode() ? (int) $code : (int) $mixed->getCode(), (int) $severity, (string) $mixed->getFile(), (int) $mixed->getLine());
} else {
if ($file !== null && $line !== null) {
parent::__construct((string) $mixed, (int) $code, (int) $severity, (string) $file, (int) $line);
} else {
parent::__construct((string) $mixed, (int) $code, (int) $severity);
}
}
if ($severity !== -1) {
self::stack($this);
}
}
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:35,代码来源:Error.php
示例15: __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
示例16: __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
示例17: __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
示例18: __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
示例19: __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
示例20: __construct
/**
* Constructor
*
* @param int $httpStatus HTTP code
* @param string $message messsage
* @param int $severity severity
*
* @return void
*/
public function __construct($message, $httpStatus = 200, array $info = array())
{
$trace = debug_backtrace();
$filename = $trace[0]['file'];
$lineno = $trace[0]['line'];
parent::__construct($message, $httpStatus, 0, $filename, $lineno);
$this->_info = $info;
}
开发者ID:sssAlchemy,项目名称:Panda,代码行数:17,代码来源:Exception.php
注:本文中的ErrorException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论