Skip to content

Commit

Permalink
add value that was found
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Dec 16, 2024
1 parent d841c78 commit 655ab75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions toml-span/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ pub enum ErrorKind {
UnexpectedValue {
/// The list of values that could have been used, eg. typically enum variants
expected: &'static [&'static str],
/// The actual value that was found.
value: Option<String>,
},
}

Expand Down Expand Up @@ -225,7 +227,7 @@ impl Display for Error {
ErrorKind::Deprecated { old, new } => {
write!(f, "field '{old}' is deprecated, '{new}' has replaced it")?;
}
ErrorKind::UnexpectedValue { expected } => write!(f, "expected '{expected:?}'")?,
ErrorKind::UnexpectedValue { expected, .. } => write!(f, "expected '{expected:?}'")?,
}

// if !self.key.is_empty() {
Expand Down Expand Up @@ -328,7 +330,7 @@ impl Error {
.with_labels(vec![
Label::primary(fid, self.span).with_message("deprecated field")
]),
ErrorKind::UnexpectedValue { expected } => diag
ErrorKind::UnexpectedValue { expected, .. } => diag
.with_message(format!("expected '{expected:?}'"))
.with_labels(vec![
Label::primary(fid, self.span).with_message("unexpected value")
Expand Down

0 comments on commit 655ab75

Please sign in to comment.