#[non_exhaustive]pub enum Error {
Show 57 variants
Message {
msg: String,
location: Location,
},
ExternalMessage {
source: ExternalMessageSource,
msg: String,
code: Option<String>,
params: Vec<(String, String)>,
location: Location,
},
Eof {
location: Location,
},
MultipleDocuments {
hint: &'static str,
location: Location,
},
Unexpected {
expected: &'static str,
location: Location,
},
MergeValueNotMapOrSeqOfMaps {
location: Location,
},
InvalidBinaryBase64 {
location: Location,
},
BinaryNotUtf8 {
location: Location,
},
TaggedScalarCannotDeserializeIntoString {
location: Location,
},
UnexpectedSequenceEnd {
location: Location,
},
UnexpectedMappingEnd {
location: Location,
},
InvalidBooleanStrict {
location: Location,
},
InvalidCharNull {
location: Location,
},
InvalidCharNotSingleScalar {
location: Location,
},
NullIntoString {
location: Location,
},
BytesNotSupportedMissingBinaryTag {
location: Location,
},
UnexpectedValueForUnit {
location: Location,
},
ExpectedEmptyMappingForUnitStruct {
location: Location,
},
UnexpectedContainerEndWhileSkippingNode {
location: Location,
},
InternalSeedReusedForMapKey {
location: Location,
},
ValueRequestedBeforeKey {
location: Location,
},
ExpectedStringKeyForExternallyTaggedEnum {
location: Location,
},
ExternallyTaggedEnumExpectedScalarOrMapping {
location: Location,
},
UnexpectedValueForUnitEnumVariant {
location: Location,
},
InvalidUtf8Input,
AliasReplayCounterOverflow {
location: Location,
},
AliasReplayLimitExceeded {
total_replayed_events: usize,
max_total_replayed_events: usize,
location: Location,
},
AliasExpansionLimitExceeded {
anchor_id: usize,
expansions: usize,
max_expansions_per_anchor: usize,
location: Location,
},
AliasReplayStackDepthExceeded {
depth: usize,
max_depth: usize,
location: Location,
},
FoldedBlockScalarMustIndentContent {
location: Location,
},
InternalDepthUnderflow {
location: Location,
},
InternalRecursionStackEmpty {
location: Location,
},
RecursiveReferencesRequireWeakTypes {
location: Location,
},
InvalidScalar {
ty: &'static str,
location: Location,
},
SerdeInvalidType {
unexpected: String,
expected: String,
location: Location,
},
SerdeInvalidValue {
unexpected: String,
expected: String,
location: Location,
},
SerdeUnknownVariant {
variant: String,
expected: Vec<&'static str>,
location: Location,
},
SerdeUnknownField {
field: String,
expected: Vec<&'static str>,
location: Location,
},
SerdeMissingField {
field: &'static str,
location: Location,
},
UnexpectedContainerEndWhileReadingKeyNode {
location: Location,
},
DuplicateMappingKey {
key: Option<String>,
location: Location,
},
TaggedEnumMismatch {
tagged: String,
target: &'static str,
location: Location,
},
SerdeVariantId {
msg: String,
location: Location,
},
ExpectedMappingEndAfterEnumVariantValue {
location: Location,
},
ContainerEndMismatch {
location: Location,
},
UnknownAnchor {
location: Location,
},
AliasError {
msg: String,
locations: Locations,
},
HookError {
msg: String,
location: Location,
},
Budget {
breach: BudgetBreach,
location: Location,
},
IOError {
cause: Error,
},
QuotingRequired {
value: String,
location: Location,
},
CannotBorrowTransformedString {
reason: TransformReason,
location: Location,
},
WithSnippet {
regions: Vec<CroppedRegion>,
crop_radius: usize,
error: Box<Error>,
},
ValidationError {
report: Report,
locations: PathMap,
},
ValidationErrors {
errors: Vec<Error>,
},
ValidatorError {
errors: ValidationErrors,
locations: PathMap,
},
ValidatorErrors {
errors: Vec<Error>,
},
}Expand description
Error type compatible with serde::de::Error.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Message
Free-form error with optional source location.
ExternalMessage
Text primarily produced by a dependency (parser / validators).
Renderers should call Localizer::override_external_message to allow callers
to replace or translate this text.
Fields
source: ExternalMessageSourceEof
Unexpected end of input.
MultipleDocuments
More than one YAML document was found when a single document was expected.
This is typically returned by single-document entrypoints like from_str* / from_slice*
/ read_to_end* when the input stream contains multiple ----delimited documents.
Unexpected
Structural/type mismatch — something else than the expected token/value was seen.
MergeValueNotMapOrSeqOfMaps
YAML merge (<<) value was not a mapping or a sequence of mappings.
InvalidBinaryBase64
!!binary scalar could not be decoded as base64.
BinaryNotUtf8
!!binary scalar decoded successfully but was not valid UTF-8 when a string was expected.
TaggedScalarCannotDeserializeIntoString
A scalar was explicitly tagged but could not be deserialized into a string.
UnexpectedSequenceEnd
Encountered a sequence end where it was not expected.
UnexpectedMappingEnd
Encountered a mapping end where it was not expected.
InvalidBooleanStrict
Invalid boolean literal in strict mode.
InvalidCharNull
Invalid char: null cannot be deserialized into char.
InvalidCharNotSingleScalar
Invalid char: expected a single Unicode scalar value.
NullIntoString
Cannot deserialize null into string.
BytesNotSupportedMissingBinaryTag
Bytes (&[u8] / Vec<u8>) are not supported unless the scalar is tagged as !!binary.
UnexpectedValueForUnit
Unexpected value for unit (()).
ExpectedEmptyMappingForUnitStruct
Unit struct expected an empty mapping.
UnexpectedContainerEndWhileSkippingNode
While skipping a node, a container end event was encountered unexpectedly.
InternalSeedReusedForMapKey
Internal error: a seed was reused for a map key.
ValueRequestedBeforeKey
Internal error: value requested before key.
ExpectedStringKeyForExternallyTaggedEnum
Externally tagged enum: expected a string key.
ExternallyTaggedEnumExpectedScalarOrMapping
Externally tagged enum: expected either a scalar or a mapping.
UnexpectedValueForUnitEnumVariant
Unexpected value for unit enum variant.
InvalidUtf8Input
Input was not valid UTF-8.
AliasReplayCounterOverflow
Alias replay counter overflow.
AliasReplayLimitExceeded
Alias replay total event limit exceeded.
AliasExpansionLimitExceeded
Alias expansion limit exceeded for a single anchor.
AliasReplayStackDepthExceeded
Alias replay stack depth limit exceeded.
FoldedBlockScalarMustIndentContent
Folded block scalars must indent their content.
InternalDepthUnderflow
Internal: depth counter underflow.
InternalRecursionStackEmpty
Internal: recursion stack empty.
RecursiveReferencesRequireWeakTypes
recursive references require weak recursion types.
InvalidScalar
Scalar parsing failed for the requested target type.
SerdeInvalidType
Serde-generated: invalid type.
SerdeInvalidValue
Serde-generated: invalid value.
SerdeUnknownVariant
Serde-generated: unknown enum variant.
SerdeUnknownField
Serde-generated: unknown field.
SerdeMissingField
Serde-generated: missing required field.
UnexpectedContainerEndWhileReadingKeyNode
Encountered the end of a sequence or mapping while reading a key node.
This indicates a structural mismatch in the input.
DuplicateMappingKey
Duplicate key in a mapping.
When the duplicate key can be rendered as a string-like scalar, key is provided.
TaggedEnumMismatch
Tagged enum name does not match the target enum.
SerdeVariantId
Serde-generated error while deserializing an enum variant identifier.
ExpectedMappingEndAfterEnumVariantValue
Expected the end of a mapping after an externally tagged enum variant value.
ContainerEndMismatch
UnknownAnchor
Alias references a non-existent anchor.
AliasError
Error related to an alias, with both reference (use-site) and defined (anchor) locations.
This variant allows reporting both where an alias is used and where the anchor is defined, which is useful for errors that occur when deserializing aliased values.
HookError
Error when parsing robotic and other extensions beyond standard YAML. (error in extension hook).
Budget
A YAML budget limit was exceeded.
IOError
Unexpected I/O error. This may happen only when deserializing from a reader.
QuotingRequired
The value is targeted to the string field but can be interpreted as a number or boolean. This error can only happen if no_schema set true.
CannotBorrowTransformedString
The target type requires a borrowed string (&str), but the value was transformed
during parsing (e.g., through escape processing, line folding, or multi-line normalization)
and cannot be borrowed from the input.
Use String or Cow<str> instead of &str to handle transformed values.
Fields
reason: TransformReasonThe reason why the string had to be transformed and cannot be borrowed.
WithSnippet
Wrap an error with the full input text, enabling rustc-like snippet rendering.
Fields
regions: Vec<CroppedRegion>Cropped source windows used for snippet rendering.
This intentionally does NOT store the full input text, to avoid retaining large YAML inputs inside errors.
ValidationError
Garde validation failure.
ValidationErrors
Garde validation failures (multiple, if multiple validations fail)
ValidatorError
Validator validation failure.
ValidatorErrors
Validator validation failures (multiple, if multiple validations fail)
Implementations§
Source§impl Error
impl Error
Sourcepub fn without_snippet(&self) -> &Self
pub fn without_snippet(&self) -> &Self
Provide “no snippet” version for cases when snippet rendering is not desired.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render this error using the built-in developer formatter.
This is the deferred-rendering entrypoint. It is equivalent to Display/to_string()
output, but also allows callers to choose a custom MessageFormatter via
Error::render_with_options.
Sourcepub fn render_with_formatter(&self, formatter: &dyn MessageFormatter) -> String
pub fn render_with_formatter(&self, formatter: &dyn MessageFormatter) -> String
Render this error using a custom message formatter.
Sourcepub fn render_with_options(&self, options: RenderOptions<'_>) -> String
pub fn render_with_options(&self, options: RenderOptions<'_>) -> String
Render this error using the provided options.
Sourcepub fn cannot_borrow_transformed(reason: TransformReason) -> Self
pub fn cannot_borrow_transformed(reason: TransformReason) -> Self
Construct a CannotBorrowTransformedString error for the given reason.
This error is returned when deserializing to &str but the string value
was transformed during parsing and cannot be borrowed from the input.
Sourcepub fn location(&self) -> Option<Location>
pub fn location(&self) -> Option<Location>
If the error has a known location, return it.
Returns:
Some(Location)when coordinates are known;Noneotherwise.
Used by:
- Callers that want to surface precise positions to users.
Sourcepub fn locations(&self) -> Option<Locations>
pub fn locations(&self) -> Option<Locations>
Return a pair of locations associated with this error.
-
For syntax and other errors that carry a single
Location, this returns two identical locations. -
For validation errors (when the
garde/validatorfeature is enabled), this returns the(reference_location, defined_location)pair for the first validation entry.These two locations may differ when YAML anchors/aliases are involved.
-
Returns
Nonewhen no meaningful location information is available.
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
Source§impl Error for Error
impl Error for Error
Source§fn custom<T: Display>(msg: T) -> Self
fn custom<T: Display>(msg: 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 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 invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
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.Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more