pub enum Error {
UnknownDataType(Span),
InvalidRustSyntax {
span: Span,
expected: String,
},
ExpectedIdent(Span),
PushParse {
span: Option<Span>,
error: PushParseError,
},
Custom {
error: String,
span: Option<Span>,
},
}
Expand description
Errors that can occur while parsing or generator your derive macro.
Variants§
UnknownDataType(Span)
The data type at Span
is unknown. This will be called when Parse::new
is called on anything that is not a struct
or enum
.
InvalidRustSyntax
The rust syntax is invalid. This can be returned while parsing the Enum or Struct.
This error is assumed to not appear as rustc will do syntax checking before virtue gets access to the TokenStream
.
However this error could still be returned.
Fields
ExpectedIdent(Span)
Expected an ident at the given span.
PushParse
Failed to parse the code passed to StreamBuilder::push_parsed
.
Fields
error: PushParseError
The internal parse error
Custom
A custom error thrown by the developer
Implementations§
source§impl Error
impl Error
sourcepub fn custom_at(s: impl Into<String>, span: Span) -> Self
pub fn custom_at(s: impl Into<String>, span: Span) -> Self
Throw a custom error at a given location
sourcepub fn custom_at_token(s: impl Into<String>, token: TokenTree) -> Self
pub fn custom_at_token(s: impl Into<String>, token: TokenTree) -> Self
Throw a custom error at a given token
source§impl Error
impl Error
sourcepub fn into_token_stream(self) -> TokenStream
pub fn into_token_stream(self) -> TokenStream
Turn this error into a TokenStream
so it shows up as a compile_error
for the user.
sourcepub fn throw_with_span(self, span: Span) -> TokenStream
pub fn throw_with_span(self, span: Span) -> TokenStream
Turn this error into a TokenStream
so it shows up as a compile_error
for the user. The error will be shown at the given span
.