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