Chris@0: rawMessage = $message; Chris@0: Chris@0: if (!empty($filename) && preg_match('{Psy[/\\\\]ExecutionLoop}', $filename)) { Chris@0: $filename = ''; Chris@0: } Chris@0: Chris@0: switch ($severity) { Chris@0: case E_STRICT: Chris@0: $type = 'Strict error'; Chris@0: break; Chris@0: Chris@0: case E_NOTICE: Chris@0: case E_USER_NOTICE: Chris@0: $type = 'Notice'; Chris@0: break; Chris@0: Chris@0: case E_WARNING: Chris@0: case E_CORE_WARNING: Chris@0: case E_COMPILE_WARNING: Chris@0: case E_USER_WARNING: Chris@0: $type = 'Warning'; Chris@0: break; Chris@0: Chris@0: case E_DEPRECATED: Chris@0: case E_USER_DEPRECATED: Chris@0: $type = 'Deprecated'; Chris@0: break; Chris@0: Chris@0: case E_RECOVERABLE_ERROR: Chris@0: $type = 'Recoverable fatal error'; Chris@0: break; Chris@0: Chris@0: default: Chris@0: $type = 'Error'; Chris@0: break; Chris@0: } Chris@0: Chris@0: $message = sprintf('PHP %s: %s%s on line %d', $type, $message, $filename ? ' in ' . $filename : '', $lineno); Chris@0: parent::__construct($message, $code, $severity, $filename, $lineno, $previous); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the raw (unformatted) message for this error. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getRawMessage() Chris@0: { Chris@0: return $this->rawMessage; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Helper for throwing an ErrorException. Chris@0: * Chris@0: * This allows us to: Chris@0: * Chris@0: * set_error_handler(array('Psy\Exception\ErrorException', 'throwException')); Chris@0: * Chris@0: * @throws ErrorException Chris@0: * Chris@0: * @param int $errno Error type Chris@0: * @param string $errstr Message Chris@0: * @param string $errfile Filename Chris@0: * @param int $errline Line number Chris@0: */ Chris@0: public static function throwException($errno, $errstr, $errfile, $errline) Chris@0: { Chris@0: throw new self($errstr, 0, $errno, $errfile, $errline); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Create an ErrorException from an Error. Chris@0: * Chris@0: * @param \Error $e Chris@0: * Chris@0: * @return ErrorException Chris@0: */ Chris@0: public static function fromError(\Error $e) Chris@0: { Chris@0: return new self($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e); Chris@0: } Chris@0: }