Skip to content

Improve the error message for deserializing IndependentStyle - #48

Merged
Drodt merged 1 commit into
typst:mainfrom
YDX-2147483647:err
Aug 1, 2026
Merged

Drodt merged 1 commit into
typst:mainfrom
YDX-2147483647:err

Conversation

@YDX-2147483647

@YDX-2147483647 YDX-2147483647 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Resolves typst/typst#8695
Continues #23

XmlDeError contains the source error and the path at which the error occurred.

citationberg/src/lib.rs

Lines 61 to 68 in 82f2b85

/// Error type for functions that deserialize XML.
#[derive(Debug, Clone)]
pub struct XmlDeError {
/// The underlying XML error.
pub source: quick_xml::de::DeError,
/// The path to the error location in the XML.
pub path: Option<serde_path_to_error::Path>,
}

Previously, XmlDeError::fmt shows only the path.
However, sometimes the source error carries important info.

citationberg/src/lib.rs

Lines 308 to 310 in 82f2b85

Style::Dependent(_) => Err(serde::de::Error::custom(
"expected an independent style but got a dependent style",
)),

For example, the above custom errors becomes the following XmlDeError.

XmlDeError {
  source: Custom("expected an independent style but got a dependent style"),
  path: Some(Path { segments: [] }),
}

This PR appends the source error after the path.

@Drodt Drodt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Drodt
Drodt merged commit 78e4149 into typst:main Aug 1, 2026
3 checks passed
@YDX-2147483647
YDX-2147483647 deleted the err branch August 1, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the error message for dependent CSL styles (v0.15 regression)

2 participants