Skip to content

refactor(error)!: Error is non_exhaustive, and failures BasicFileInfo and Cfb did not describe get their own variants - #898

Merged
DrunkOnJava merged 9 commits into
mainfrom
refactor/error-variants
Oct 23, 2026
Merged

DrunkOnJava merged 9 commits into
mainfrom
refactor/error-variants

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Error becomes #[non_exhaustive] and gains four variants that say what failed, replacing the places that reported unrelated failures as Error::BasicFileInfo (39 before this PR and #894) or Error::Cfb:

Variant Was Raised by
SchemaMismatch { decoder, schema } BasicFileInfo("WallDecoder received wrong schema: ...") every typed decoder, SimpleDecoder, the ArcWall decoder
NoDecoder(class) BasicFileInfo("no typed decoder registered for class ...") elements::decode_typed*
MissingClass("ADocument") BasicFileInfo("ADocument not in schema") the ADocument walk
Malformed { what, detail } BasicFileInfo(...), Cfb("ArcWall decode: ...") ADocument decode, Global/ElemTable, ArcWall and opening-index records

Every variant is now documented, and src/error.rs has a module doc.

Motivation

The 2026-10-23 style audit (Rust API Guidelines C-GOOD-ERR; Google's "Reporting errors"; #[non_exhaustive] on public enums). Error already gained variants three times; each was a breaking change for anyone matching on it. Error is part of the stable API under #873, so this belongs before 1.0. Depends on #894 (it converts SimpleDecoder's error); until #894 merges, this PR's diff includes #894's.

Changes

  • src/error.rs: #[non_exhaustive], the four variants, docs.
  • 8 hand-written decoders, SimpleDecoder, elements::arc_wall, elements/mod.rs, walker.rs, elem_table.rs, arc_wall_record.rs, rect_opening_index.rs: the conversions (script, then rustfmt).
  • CHANGELOG.md: a breaking Changed entry.

Not changed: the existing variants' payloads and messages (tests/rvt_info_cli.rs, a Python test and the Python package's docs quote them), and writer::file_guid's BasicFileInfo, which does describe a BasicFileInfo parse failure. Cfb(String) still drops its source error: its 26 sites each format their own context, so keeping the source is a payload change with its own design, tracked in #899.

Testing

No unit tests (banned). The matches on Error outside the crate (rvt-py, rvt-info, rvt-corpus, the tests) already have wildcard arms; CI builds all of them. Nothing asserts on the replaced messages. Measure is unaffected: no decode path changes, only the error a refusal carries.

  • CI

Audit-honesty checklist

  • Docs match the code
  • No emojis, private paths or internal jargon

Legal and contribution hygiene

  • Apache-2.0

Breaking changes

match on rvt::Error needs a wildcard arm. Code that matched Error::BasicFileInfo or Error::Cfb to catch a wrong-schema, missing-decoder or malformed-record failure matches the new variant instead.

Screenshots or output samples

N/A.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review October 23, 2026 12:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57455181ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/error.rs Resolved
Comment thread src/elements/arc_wall.rs Resolved
Comment thread src/error.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a2e0c29bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/elements/simple_decoder.rs Resolved
Comment thread src/walker.rs Resolved
Comment thread rvt-py/src/lib.rs Resolved
# Conflicts:
#	CHANGELOG.md
…alformed; a schema without ADocument raises ValueError in Python
@DrunkOnJava
DrunkOnJava merged commit 5bcd9ea into main Oct 23, 2026
27 checks passed
@DrunkOnJava
DrunkOnJava deleted the refactor/error-variants branch October 23, 2026 14:00
Repository owner deleted a comment from chatgpt-codex-connector Bot Oct 31, 2026
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.

1 participant