Any Display error works, including Box<dyn Error> — and it already did - #8
Merged
Conversation
zmaril
force-pushed
the
feat/boxed-error
branch
from
August 18, 2026 16:37
b4a7f4a to
5b1dab5
Compare
zmaril
force-pushed
the
feat/boxed-error
branch
from
August 18, 2026 20:44
5b1dab5 to
f3a634e
Compare
zmaril
force-pushed
the
feat/boxed-error
branch
from
August 18, 2026 20:45
f3a634e to
e450b20
Compare
Item 5, with a correction: the premise was wrong, and the wrongness was mine. The complaint was that a function which can fail two ways had to flatten to Result<_, String> and litter itself with .map_err(|e| e.to_string()) -- six such calls in jawohl's surface. But jedem never inspected the error type. Every backend renders failure as that language's own mechanism carrying the error's Display text, so Box<dyn Error> and anyhow::Error have always worked. jawohl's map_err calls were self-inflicted. So this commit does not add a feature. It proves the behaviour with tests, says so in the docs where someone would look, and demonstrates it in the demo: a function returning Result<i64, Box<dyn Error>> that fails two different ways -- a parse error and a domain error -- crosses to Python and Node with each message intact. jawohl's surface can now drop its six map_err calls; that is a change in the jawohl repo. While adding the demo, cargo fmt broke the drift guard again -- the fourth occurrence of the same class. This time it collapsed a double blank line between two interfaces. The previous three were a trailing space on an empty doc line, a trailing blank line at end of file, and the same again per backend. Patching the emitter a fourth time would have been the wrong response, so the invariants are now central: a normalise() step every backend's output passes through, enforcing no trailing whitespace, no run of blank lines, and exactly one terminal newline. Tests assert each invariant across Target::ALL, plus one that generation is normalisation-stable -- what jedem writes is what rustfmt would leave alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HsDxLrGdx6nPaXkVEWkNvS
zmaril
force-pushed
the
feat/boxed-error
branch
from
August 18, 2026 20:46
e450b20 to
fdfd8c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7. Item 5, with a correction: the premise was wrong, and the
wrongness was mine.
I reported that a function which can fail two ways had to flatten to
Result<_, String>and litter itself with.map_err(|e| e.to_string())— sixsuch calls in jawohl's surface. But jedem never inspected the error type.
Every backend renders failure as that language's own mechanism carrying the
error's
Displaytext, soBox<dyn Error>andanyhow::Errorhave alwaysworked. jawohl's
map_errcalls were self-inflicted.So this adds no feature. It proves the behaviour, documents it where someone
would look, and demonstrates it:
jawohl's surface can now drop its six
map_errcalls — a change in thejawohl repo, which I'll make there.
The fourth occurrence of one bug class
While adding the demo,
cargo fmtbroke the drift guard again — this timecollapsing a double blank line between two interfaces. The previous three were a
trailing space on an empty doc line, a trailing blank line at EOF, and the same
again per backend.
Patching the emitter a fourth time would have been the wrong response. The
invariants are now central: a
normalise()step every backend's outputpasses through, enforcing no trailing whitespace, no run of blank lines, exactly
one terminal newline. Tests assert each across
Target::ALL, plus one thatgeneration is normalisation-stable — what jedem writes is what rustfmt would
leave alone.
39 tests, clippy clean, both round-trips passing.
Next and last of the series:
#[derive(Enum)].🤖 Generated with Claude Code
https://claude.ai/code/session_01HsDxLrGdx6nPaXkVEWkNvS