pub enum Error {
InvalidUtf8 {
location: Box<Location>,
},
UnsupportedType {
text: String,
location: Box<Location>,
found: &'static str,
},
Parse {
text: String,
location: Option<Box<Location>>,
message: String,
},
Deserialize {
text: String,
message: String,
location: Option<Box<Location>>,
},
}Expand description
Error while deserializing configuration input.
Display is one line by default; use {error:#} for source context and caret.
Location is boxed so the whole Error stays small enough to return by value without
tripping clippy::result_large_err (a Location now carries the full originating
tanzim_source::Source).
Variants§
InvalidUtf8
UnsupportedType
Parse
Deserialize
A value could not be deserialized into the requested type (serde Cargo feature).
text holds the raw source of the offending value’s origin (empty until supplied via
Error::with_source_text); when present, {error:#} renders a caret underline.
Implementations§
Source§impl Error
impl Error
Sourcepub fn deserialize_location(&self) -> Option<&Location>
pub fn deserialize_location(&self) -> Option<&Location>
The Location of a located Error::Deserialize, if any. Lets a caller (e.g. the
pipeline) look up the originating source and fill in Error::with_source_text.
Sourcepub fn with_source_text(self, text: impl Into<String>) -> Self
pub fn with_source_text(self, text: impl Into<String>) -> Self
Attach the raw source text of the offending value’s origin to a Error::Deserialize
(only if it has none yet), so {error:#} can render a source snippet with a caret.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl Error for Error
impl Error for Error
Source§fn custom<T: Display>(message: T) -> Self
fn custom<T: Display>(message: T) -> Self
Source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a type different from what it was
expecting. Read moreSource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a value of the right type but that
is wrong for some other reason. Read moreSource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Deserialize enum type received a variant with an
unrecognized name.Source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Deserialize struct type received a field with an
unrecognized name.Source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Deserialize struct type expected to receive a required
field with a particular name but that field was not present in the
input.Source§fn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Deserialize struct type received more than one of the
same field.