예제 #1
0
 /**
  * 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);
 }
 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
0
 /**
  * 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
0
 /**
  * @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);
 }
 /**
  * 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);
     }
 }
 /**
  * @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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
파일: aerror.php 프로젝트: OpenBX/obx.core
 /**
  * @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
0
 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
0
 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
0
 /**
  * @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']);
     }
 }
예제 #16
0
 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());
 }
예제 #17
0
 public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null)
 {
     parent::__construct($message, $code, $severity, $filename, $lineno);
     if (null !== $trace) {
         if (!$traceArgs) {
             foreach ($trace as &$frame) {
                 unset($frame['args'], $frame['this'], $frame);
             }
         }
         $this->setTrace($trace);
     } elseif (null !== $traceOffset) {
         if (function_exists('xdebug_get_function_stack')) {
             $trace = xdebug_get_function_stack();
             if (0 < $traceOffset) {
                 array_splice($trace, -$traceOffset);
             }
             foreach ($trace as &$frame) {
                 if (!isset($frame['type'])) {
                     // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
                     if (isset($frame['class'])) {
                         $frame['type'] = '::';
                     }
                 } elseif ('dynamic' === $frame['type']) {
                     $frame['type'] = '->';
                 } elseif ('static' === $frame['type']) {
                     $frame['type'] = '::';
                 }
                 // XDebug also has a different name for the parameters array
                 if (!$traceArgs) {
                     unset($frame['params'], $frame['args']);
                 } elseif (isset($frame['params']) && !isset($frame['args'])) {
                     $frame['args'] = $frame['params'];
                     unset($frame['params']);
                 }
             }
             unset($frame);
             $trace = array_reverse($trace);
         } elseif (function_exists('symfony_debug_backtrace')) {
             $trace = symfony_debug_backtrace();
             if (0 < $traceOffset) {
                 array_splice($trace, 0, $traceOffset);
             }
         } else {
             $trace = array();
         }
         $this->setTrace($trace);
     }
 }
예제 #18
0
 /**
  * ConnectionException constructor.
  *
  * @param Request $request
  * @param int $message
  * @param int $code
  * @param \Throwable $previous
  */
 public function __construct(Request $request, string $message, int $code = null, \Throwable $previous = null)
 {
     $this->request = $request;
     $message = sprintf('[%s %s] [ERROR %s] ', $request->getMethod(), $request->getUri()->get(false, false), $code) . htmlspecialchars($message);
     $filename = __FILE__;
     $lineno = __LINE__;
     $debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($debug as $index => $backtrace) {
         if (isset($backtrace['class']) && stripos($backtrace['class'], 'Cawa\\HttpClient\\') !== false && (empty($debug[$index + 1]['class']) || !empty($debug[$index + 1]['class']) && stripos($debug[$index + 1]['class'], 'Cawa\\HttpClient\\') === false)) {
             $filename = $debug[$index]['file'];
             $lineno = $debug[$index]['line'];
             break;
         }
     }
     parent::__construct($message, $code, 1, $filename, $lineno, $previous);
 }
예제 #19
0
파일: Error.php 프로젝트: xamiro-dev/xamiro
 /**
  * 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);
     }
 }
예제 #20
0
 /**
  * Constructor
  *
  * @param ConstraintViolationList|array|string $errors
  */
 public function __construct($errors)
 {
     if ($errors instanceof ConstraintViolationList) {
         $errorFields = array();
         foreach ($errors as $error) {
             $attrSnake = $this->convertToSnakeCase($error->getPropertyPath());
             $errorFields[$attrSnake][] = $error->getMessage();
         }
         $errorMessage = json_encode($errorFields);
     } elseif (is_array($errors)) {
         $errorFields = $errors;
         $errorMessage = json_encode($errorFields);
     } else {
         $errorFields = $errors;
         $errorMessage = $errors;
     }
     parent::__construct($errorMessage);
     $this->setErrorFields($errorFields);
 }
 /**
  * Construct a Psy ErrorException.
  *
  * @param string    $message  (default: "")
  * @param int       $code     (default: 0)
  * @param int       $severity (default: 1)
  * @param string    $filename (default: null)
  * @param int       $lineno   (default: null)
  * @param Exception $previous (default: null)
  */
 public function __construct($message = '', $code = 0, $severity = 1, $filename = null, $lineno = null, $previous = null)
 {
     $this->rawMessage = $message;
     if (!empty($filename) && preg_match('{Psy[/\\\\]ExecutionLoop}', $filename)) {
         $filename = null;
     }
     switch ($severity) {
         case E_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
         case E_USER_WARNING:
             $type = 'warning';
             break;
         case E_STRICT:
             $type = 'Strict error';
             break;
         default:
             $type = 'error';
             break;
     }
     $message = sprintf('PHP %s:  %s%s on line %d', $type, $message, $filename ? ' in ' . $filename : '', $lineno);
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
 }
예제 #22
0
 public function __construct($message, $code = 0, $severity = E_USER_NOTICE, Exception $previous = null)
 {
     parent::__construct($message, $code, $severity, $previous);
 }
예제 #23
0
 public function __construct($message = "", $code = 0, $severity = 1, $filename = null, $lineno = null, $previous = null)
 {
     switch ($severity) {
         case E_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
         case E_USER_WARNING:
             $type = 'warning';
             break;
         case E_STRICT:
             $type = 'Strict error';
             break;
         default:
             $type = 'error';
             break;
     }
     $message = sprintf('PHP %s:  %s', $type, $message);
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
 }
 /**
  * Create a fatal error.
  *
  * @param string     $message  (default: "")
  * @param int        $code     (default: 0)
  * @param int        $severity (default: 9000)
  * @param string     $filename (default: null)
  * @param int        $lineno   (default: null)
  * @param \Exception $previous (default: null)
  */
 public function __construct($message = '', $code = 0, $severity = 9000, $filename = null, $lineno = null, $previous = null)
 {
     $this->rawMessage = $message;
     $message = sprintf('PHP Fatal error:  %s in %s on line %d', $message, $filename ?: "eval()'d code", $lineno);
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
 }
예제 #25
0
 public function __construct($Message, $ErrorNumber, $File, $Line, $Context, $Backtrace)
 {
     parent::__construct($Message, $ErrorNumber, 0, $File, $Line);
     $this->_Context = $Context;
 }
예제 #26
0
 public function __construct($message = null)
 {
     parent::__construct($message, 404);
 }
 public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
 {
     parent::__construct($message, $code, $severity, $filename, $lineno);
     $this->context = $context;
 }
 /**
  * @param null $data
  * @param null $id
  */
 public function __construct($data = null, $id = null)
 {
     parent::__construct('Invalid Request', -32600, $data, $id);
 }
예제 #29
0
 /**
  * error exception class constructor directs instance
  * to error xapp error handling
  *
  * @param string $message excepts error message
  * @param int $code expects error code
  * @param int $severity expects severity flag
  */
 public function __construct($message, $code = 0, $severity = XAPP_ERROR_ERROR)
 {
     parent::__construct($message, $code, $severity);
     xapp_error($this);
 }
예제 #30
0
	public function __construct($message, $code, $severity, $file, $line, $context)
	{
		parent::__construct($message, $code, $severity, $file, $line);
		$this->context = $context;
	}