Struct apollo_parser::Error
source · [−]pub struct Error { /* private fields */ }
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
sourceimpl Error
impl Error
sourcepub fn with_loc<S: Into<String>>(message: S, data: String, index: usize) -> Self
pub fn with_loc<S: Into<String>>(message: S, data: String, index: usize) -> Self
Create a new instance of Error
with a Location
.
sourcepub fn data(&self) -> &str
pub fn data(&self) -> &str
Get a reference to the error’s data. This is usually the token that
apollo-parser
has found to be lexically or syntactically incorrect.
Trait Implementations
impl Eq for Error
impl StructuralEq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more