Repository navigation
Add HotCell::Verdict so a raised exception carries its failure - #104
Merged
Merged
Conversation
The client raises the application's own classes with failure.to_s as the message, so an application reading the code or cause had to parse the message. Verdict.wrap now extends the exception with the failure itself — and because Verdict is a module on the instance, an application can also rescue HotCell::Verdict directly, whatever classes its registration injected.
flavorjones
force-pushed
the
card-644-failure-on-raised-exception
branch
from
October 7, 2026 21:28
e020783 to
87ef1a2
Compare
Describe `hot_cell_failure` and `rescue HotCell::Verdict` under "Exception classes" in `docs/codes.md`, and link there from `docs/client-api.md`. [Fix #97]
The legacy client exposed a failure as a `code` reader and a raw `error` Hash, unlike `hotcell-client`'s `hot_cell_failure`. Replace both with `hot_cell_failure`, which returns a `Failure` with the readers of `HotCell::Failure`. Include a new `Verdict` module in both failure classes, so `rescue Verdict` catches either.
flavorjones
force-pushed
the
card-644-failure-on-raised-exception
branch
from
October 7, 2026 21:34
87ef1a2 to
4fdba63
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.
Motivation
The client raises the application's registered
permanent:ortransient:class withfailure.to_sas the message (client.rb#L203). An application that needs the failure'scodeorcausehas to parse that message. HEY does this to show a lock placeholder for a password-protected PDF: it matchesmutool's stderr inside the message (encryption_aware_pdf_previewer.rb#L27).Fixes #97
Details
This is Donal's
carry-the-failurebranch, rebased ontomaster, with docs, a changelog entry, and the same change to the legacy client.The client now extends each exception it raises for a failed call with a new
HotCell::Verdictmodule. The module'shot_cell_failurereader returns theHotCell::Failure, so an application can rescue its own class and read the code and cause directly, such as theprotectedcause that #96 added:Because
Verdictis a module on the instance, an application can alsorescue HotCell::Verdictto catch a failed call whatever classes it registered. The exception's class and message are unchanged.docs/codes.mddocuments the module under "Exception classes", anddocs/client-api.mdlinks there.hotcell-client-legacy(#102) now follows the same pattern. ItsPermanentFailureandTransientFailureinclude aHotCell::Client::Legacy::Verdictmodule, andhot_cell_failurereturns aHotCell::Client::Legacy::Failurewith the same readers asHotCell::Failure. These replace thecodereader and the rawerrorHash. The gem is unreleased, so no application depends on the old readers.