pub struct GraphQLParseError { /* private fields */ }Expand description
A parse error with location information and contextual notes.
This structure provides comprehensive error information for both human-readable CLI output and programmatic handling by tools.
Implementations§
Source§impl GraphQLParseError
impl GraphQLParseError
Sourcepub fn new(
message: impl Into<String>,
span: GraphQLSourceSpan,
kind: GraphQLParseErrorKind,
) -> Self
pub fn new( message: impl Into<String>, span: GraphQLSourceSpan, kind: GraphQLParseErrorKind, ) -> Self
Creates a new parse error with no notes.
Sourcepub fn with_notes(
message: impl Into<String>,
span: GraphQLSourceSpan,
kind: GraphQLParseErrorKind,
notes: GraphQLErrorNotes,
) -> Self
pub fn with_notes( message: impl Into<String>, span: GraphQLSourceSpan, kind: GraphQLParseErrorKind, notes: GraphQLErrorNotes, ) -> Self
Creates a new parse error with notes.
Sourcepub fn from_lexer_error(
message: impl Into<String>,
span: GraphQLSourceSpan,
lexer_notes: GraphQLErrorNotes,
) -> Self
pub fn from_lexer_error( message: impl Into<String>, span: GraphQLSourceSpan, lexer_notes: GraphQLErrorNotes, ) -> Self
Creates a parse error from a lexer error token.
When the parser encounters a GraphQLTokenKind::Error token, this
method converts it to a GraphQLParseError, preserving the lexer’s
message and notes.
Sourcepub fn span(&self) -> &GraphQLSourceSpan
pub fn span(&self) -> &GraphQLSourceSpan
Returns the primary span where the error was detected.
Sourcepub fn kind(&self) -> &GraphQLParseErrorKind
pub fn kind(&self) -> &GraphQLParseErrorKind
Returns the categorized error kind.
Sourcepub fn notes(&self) -> &GraphQLErrorNotes
pub fn notes(&self) -> &GraphQLErrorNotes
Returns the additional notes for this error.
Sourcepub fn add_note_with_span(
&mut self,
message: impl Into<String>,
span: GraphQLSourceSpan,
)
pub fn add_note_with_span( &mut self, message: impl Into<String>, span: GraphQLSourceSpan, )
Adds a general note with a span (pointing to a related location).
Sourcepub fn add_help_with_span(
&mut self,
message: impl Into<String>,
span: GraphQLSourceSpan,
)
pub fn add_help_with_span( &mut self, message: impl Into<String>, span: GraphQLSourceSpan, )
Adds a help note with a span.
Sourcepub fn format_detailed(&self, source: Option<&str>) -> String
pub fn format_detailed(&self, source: Option<&str>) -> String
Formats this error as a diagnostic string for CLI output.
Produces output like:
error: Expected `:` after field name
--> schema.graphql:5:12
|
5 | userName String
| ^^^^^^ expected `:`
|
= note: Field definitions require `:` between name and type
= help: Did you mean: `userName: String`?§Arguments
source: Optional source text for snippet extraction. IfNone, snippets are omitted but line/column info is still shown.
Sourcepub fn format_oneline(&self) -> String
pub fn format_oneline(&self) -> String
Formats this error as a single-line summary.
Produces output like:
schema.graphql:5:12: error: Expected `:` after field nameTrait Implementations§
Source§impl Clone for GraphQLParseError
impl Clone for GraphQLParseError
Source§fn clone(&self) -> GraphQLParseError
fn clone(&self) -> GraphQLParseError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more