Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/mdbook-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl Config {
value
.clone()
.try_into()
.with_context(|| "Failed to deserialize `{name}`")
.with_context(|| format!("Failed to deserialize `{name}`"))
})
.transpose()
}
Expand Down Expand Up @@ -1147,4 +1147,18 @@ mod tests {
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
}

#[test]
fn get_deserialize_error() {
let src = r#"
[preprocessor.foo]
x = 123
"#;
let cfg = Config::from_str(src).unwrap();
let err = cfg.get::<String>("preprocessor.foo.x").unwrap_err();
assert_eq!(
err.to_string(),
"Failed to deserialize `preprocessor.foo.x`"
);
}
}