本文整理汇总了PHP中ErrorException::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException::__construct方法的具体用法?PHP ErrorException::__construct怎么用?PHP ErrorException::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorException
的用法示例。
在下文中一共展示了ErrorException::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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);
}
示例2: __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);
}
示例3: __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);
}
示例4: __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);
}
示例5: __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')) {
$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'];
}
}
$ref = new \ReflectionProperty('Exception', 'trace');
$ref->setAccessible(true);
$ref->setValue($this, $trace);
}
}
示例6: __construct
/**
* @param string $message
* @param int $code
* @param int $severity
* @param string $filename
* @param int $lineno
* @param \Exception $previous
*/
public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, \Exception $previous = null)
{
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
try {
AppKernel::log('error', $this->getMessage(), array('code' => $code, 'exception' => $this));
} catch (\Exception $e) {
}
}
示例7: __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;
}
示例8: __construct
/**
* Construction of the error - a message is needed (1st argument)
*
* @param string $message The error message
* @param numeric $code The error code
* @param numeric $severity The error severity code
* @param string $filename The file name of the error
* @param numeric $lineno The line number of the error
* @param misc $previous The previous error if so
*/
public function __construct($message, $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
{
// This error code is not in the error_reporting()
if (!(error_reporting() & $code)) {
return;
}
// We let the default PHP Exception manager construction
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
$this->trace = parent::getTrace();
$this->previous = parent::getPrevious();
if (isset($php_errormsg)) {
$this->php_error_message = $php_errormsg;
}
switch ($this->getCode()) {
case E_ERROR:
case E_USER_ERROR:
$this->setType('fatal');
$this->setScope('Fatal Error');
$this->exit = true;
break;
case E_WARNING:
case E_USER_WARNING:
$this->setType('warning');
$this->setScope('Warning');
break;
case E_NOTICE:
case E_USER_NOTICE:
case @E_STRICT:
$this->setType('notice');
$this->setScope('Notice');
break;
case @E_RECOVERABLE_ERROR:
$this->setType('catchable');
$this->setScope('Catchable Error');
break;
case E_PARSE:
$this->setType('parse');
$this->setScope('Parsing Error');
break;
case @E_DEPRECATED:
case @E_USER_DEPRECATED:
$this->setType('deprecated');
$this->setScope('Deprecated Error');
break;
default:
$this->setType('unknown');
$this->setScope('Unknown Error');
$this->exit = true;
break;
}
$dom_id = Profiler::getNewDomId($this->getType());
$this->infos = array('message' => self::_buildExceptionStr(), 'scope' => $this->getScope(), 'type' => $this->getType(), 'file' => $this->getFile(), 'line' => $this->getLine(), 'severity' => $this->getSeverity(), 'filename' => basename($this->getFile()), 'dirname' => dirname($this->getFile()), 'dom_id' => $dom_id, 'source' => Profiler::getHighlightedSource($this->getFile(), $this->getLine()));
$this->infos['traces'] = Profiler::getHighlightedTraces($this->getTrace(), $this->infos);
$this->debugger = Debugger::getInstance();
$this->debugger->addStack('message', $this->infos);
$this->debugger->setDebuggerTitle(self::_buildExceptionStr(true), Url::getRequestUrl());
return false;
}
示例9: __construct
public function __construct($message, $code, $severity, $filename, $lineno, $previous)
{
if ($previous instanceof Exception) {
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
} else {
parent::__construct($message, $code, $severity, $filename, $lineno);
$this->context = $previous;
}
}
示例10: __construct
/**
* Constructor.
*
* @param array $arr The error array
*
* @codeCoverageIgnore
*/
public function __construct(array $arr)
{
$message = isset($arr['message']) ? $arr['message'] : 'There was an error parsing the file';
$code = isset($arr['code']) ? $arr['code'] : 0;
$severity = isset($arr['type']) ? $arr['type'] : 1;
$file = isset($arr['file']) ? $arr['file'] : __FILE__;
$line = isset($arr['line']) ? $arr['line'] : __LINE__;
$exception = isset($arr['exception']) ? $arr['exception'] : null;
parent::__construct($message, $code, $severity, $file, $line, $exception);
}
示例11: __construct
/**
* Constructor
*
* @param array $error
* @return void
*/
public function __construct(array $error)
{
$message = $error['message'];
$code = isset($error['code']) ? $error['code'] : 0;
$severity = isset($error['type']) ? $error['type'] : 1;
$filename = isset($error['file']) ? $error['file'] : __FILE__;
$lineno = isset($error['line']) ? $error['line'] : __LINE__;
$exception = isset($error['exception']) ? $error['exception'] : null;
parent::__construct($message, $code, $severity, $filename, $lineno, $exception);
}
示例12: __construct
/**
* @param string|array $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
* @param int $severity [optional] The severity level of the exception.
* @param string $filename [optional] The filename where the exception is thrown.
* @param int $lineno [optional] The line number where the exception is thrown.
* @param \Exception $previous [optional] The previous exception used for the exception chaining.
*/
public function __construct($message = '', $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, $previous = null)
{
if (empty($message)) {
$message = static::getLangMessage($code);
} elseif (is_array($message)) {
$arReplace = $message;
$message = static::getLangMessage($code, $arReplace);
}
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
}
示例13: __construct
public function __construct($message = '', $code = 0, $previous = null)
{
if (is_an_array($message)) {
$error = Ar($message);
$this->column = $error->column;
$this->message = $error->message;
} else {
$this->column = '(column not set)';
}
return parent::__construct($this->message, $code, $previous);
}
示例14: array
function __construct($message, $code = null, $severity = E_ERROR, $filename = null, $line = null, array $vars = array())
{
parent::__construct($message, $code, $severity, $filename, $line);
$this->message = $message;
$this->code = isset($this->codes[$code]) ? $this->codes[$code] : $code;
$this->severity = $severity;
$this->file = $filename;
$this->line = $line;
$this->vars = $vars;
$this->logErrors();
}
示例15: __construct
/**
* @param string $message
* @param int $traceOffset
*/
public function __construct($message = "", $traceOffset = 0)
{
parent::__construct($message);
$trace = $this->getTrace();
$current = $trace[$traceOffset];
$trace = array_slice($trace, $traceOffset + 1);
$this->setTrace($trace);
if (isset($current['line'])) {
$this->setLine($current['line']);
}
if (isset($current['file'])) {
$this->setFile($current['file']);
}
}