示例#1
0
 /**
  * Get a ErrorException instance.
  *
  * @param \ParseError|\TypeError|\Throwable $exception
  *
  * @return \ErrorException
  */
 private function getErrorException($exception) : ErrorException
 {
     if ($exception instanceof ParseError) {
         $message = 'Parse error: ' . $exception->getMessage();
         $severity = E_PARSE;
     } elseif ($exception instanceof TypeError) {
         $message = 'Type error: ' . $exception->getMessage();
         $severity = E_RECOVERABLE_ERROR;
     } else {
         $message = $exception->getMessage();
         $severity = E_ERROR;
     }
     return new ErrorException($message, $exception->getCode(), $severity, $exception->getFile(), $exception->getLine());
 }
 /**
  * Create a TypeErrorException from a TypeError.
  *
  * @param \TypeError $e
  *
  * @return TypeErrorException
  */
 public static function fromTypeError(\TypeError $e)
 {
     return new self($e->getMessage(), $e->getLine());
 }