Struct apollo_parser::Error [−][src]
pub struct Error { /* fields omitted */ }
Expand description
An Error
type for operations performed in the lexer and the parser.
Errors get returned alongside the resulting AST if either the lexer or the parser encouter lexical or syntactical errors respectively.
We encourage you to check for the AST’s errors before proceeding to iterate over the AST’s nodes:
Example
use apollo_parser::Parser;
let input = "union SearchResult = Photo | Person | Cat | Dog";
let parser = Parser::new(input);
let ast = parser.parse();
assert_eq!(0, ast.errors().len());
let doc = ast.document();
Diagnostics
Using something like miette crate along with apollo-parser lets you have more visual diagnostics. miette and annotate_snippets examples guide you through integrating them with apollo-parser. These are useful if you are displaying Errors in a terminal-like environment.

Implementations
Create a new instance of Error
with a Location
.
Get a reference to the error’s data. This is usually the token that
apollo-parser
has found to be lexically or syntactically incorrect.
Get a reference to the error’s index. This is where the error begins in a given input.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Error
impl UnwindSafe for Error
Blanket Implementations
Mutably borrows from an owned value. Read more