Skip to content

Commit

Permalink
Add Error::unknown_field_path_with_alts
Browse files Browse the repository at this point in the history
  • Loading branch information
TedDriggs committed Feb 23, 2024
1 parent 6158749 commit a1fda4d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ impl Error {
Error::new(ErrorUnknownField::with_alts(field, alternates).into())
}

/// Creates a new error for a field name that appears in the input but does not correspond to
/// a known attribute. The second argument is the list of known attributes; if a similar name
/// is found that will be shown in the emitted error message.
pub fn unknown_field_path_with_alts<'a, T, I>(field: &Path, alternates: I) -> Self
where
T: AsRef<str> + 'a,
I: IntoIterator<Item = &'a T>,
{
Error::new(ErrorUnknownField::with_alts(&path_to_string(field), alternates).into())
}

/// Creates a new error for a struct or variant that does not adhere to the supported shape.
pub fn unsupported_shape(shape: &str) -> Self {
Error::new(ErrorKind::UnsupportedShape {
Expand Down

0 comments on commit a1fda4d

Please sign in to comment.