/** * @param string $namespace_prefix * @param string $namespace_url * @param string $component_name * @param ComponentsProviderInterface $components * @param int $code * @param Exception $previous */ public function __construct($namespace_prefix, $namespace_url, $component_name, ComponentsProviderInterface $components, $code = 0, Exception $previous = null) { $known_components = $components->getNamespace($namespace_url)->getComponents(); $known_components = implode(', ', array_map(function (ComponentDefinition $d) use($namespace_prefix) { return "<{$namespace_prefix}:{$d->getName()}>"; }, $known_components)); parent::__construct("Component not found in a registered namespace: <{$namespace_prefix}:{$component_name}>.\n" . "Known components in '{$namespace_url}' namespace: " . $known_components, $code, $previous); }
/** * Parse * * @param text.parser.generic.AbstractLexer lexer * @return var result of the last reduction, if any. * @throws text.parser.generic.ParseException if an exception occurs during parsing. */ public function parse(AbstractLexer $lexer) { $this->messages = array(self::ERROR => array(), self::WARNING => array()); try { $result = $this->yyparse($lexer); } catch (Throwable $e) { throw new ParseException($e->getMessage(), $e); } if (!empty($this->messages[self::ERROR])) { $p = new ParseException(sizeof($this->messages[self::ERROR]) . ' parse error(s) occurred.', NULL, $this->messages[self::ERROR]); $p->setCause(new FormatException("[\n" . $p->formattedErrors() . ']')); throw $p; } return $result; }
/** * Constructs a Parse\ParseAggregateException * * @param string $message Message for the Exception. * @param array $errors Collection of error values. * @param \Exception $previous Previous exception. */ public function __construct($message, $errors = array(), $previous = null) { parent::__construct($message, 600, $previous); $this->errors = $errors; }
/** * Creates the exception. * * You should pass a list of LibXMLError objects in its constructor. * * @param LibXMLError[] $errors * @param int $code * @param Exception $previousException */ function __construct(array $errors, $code = null, Exception $previousException = null) { $this->errors = $errors; parent::__construct($errors[0]->message . ' on line ' . $errors[0]->line . ', column ' . $errors[0]->column, $code, $previousException); }
/** * @covers adamblake\parse\ParseException::errorHandler */ public function testErrorHandlerFunctionThrowsParseExceptions() { $this->expectException(ParseException::class); $this->expectExceptionMessage('e'); ParseException::errorHandler(0, 'e', __FILE__, __LINE__); }
public function __construct($actual, $expected, $file, $line, $col) { $this->token = $actual; $msg = sprintf("Unexpected token %s, expected %s", $actual, $expected); parent::__construct($msg, $file, $line, $col); }