Errors¶
Two error enums, both #[non_exhaustive], both deriving Debug,
Clone, thiserror::Error and miette::Diagnostic.
#[non_exhaustive] means a match over either one needs a _ arm
even when it covers every variant listed here. A new variant in a later
release is a minor version bump, not a breaking change, so write the
_ arm to do something sensible rather than unreachable!().
Clone is derived on both so an error can be stored, retried against,
or attached to a telemetry event without being consumed.
WizardError¶
#[non_exhaustive]
pub enum WizardError {
Cancelled,
Interrupted,
Step { step: String, message: String },
}
| Variant | Display output |
Diagnostic code | Raised when |
|---|---|---|---|
Cancelled |
wizard cancelled |
rtb::tui::wizard_cancelled |
The user went back past the first step, by returning StepOutcome::Back or by pressing Esc there |
Interrupted |
wizard interrupted (Ctrl+C) |
rtb::tui::wizard_interrupted |
Any step returned InquireError::OperationInterrupted |
Step { step, message } |
wizard step `<step>` failed: <message> |
rtb::tui::wizard_step |
Any other InquireError came out of a step |
Cancelled and Interrupted are deliberately separate. Both mean the
wizard did not finish, but one is a user deciding not to proceed and
the other is a signal — and a caller that maps them to process exit
codes normally wants different numbers for the two. See
Map wizard errors to exit codes.
Fields on WizardError::Step¶
step: String— the valueWizardStep::name()returned for the failing step, cloned into an ownedString.message: String— the underlyingInquireError'sDisplayoutput, already stringified.
The original InquireError is not retained, so there is no source()
chain back to it and no way to match on the original variant. If a
caller needs to branch on the specific inquire failure, it has to do
so inside the step, before returning.
RenderError¶
| Variant | Display output |
Diagnostic code | Raised when |
|---|---|---|---|
Json(String) |
JSON serialisation failed: <message> |
rtb::tui::render_json |
serde_json rejected the rows passed to render_json |
There is no variant for render_table, because render_table returns
String rather than a Result — see
Render helpers.
The payload is a stringified serde_json::Error, not the error itself,
so line and column information is only present if serde_json put it
in the message.
Rendering these errors with miette¶
Both enums derive miette::Diagnostic and carry a code(...), so a
binary that already reports through miette gets the code printed with
the message. miette is a hard dependency of this crate with its
fancy feature enabled — there is no way to opt out of it, and it is
by some distance the largest thing the crate pulls in. See
Crate metadata.
None of the variants carry a help(...), a url(...) or a labelled
source span. What miette adds over plain Display here is the
diagnostic code and consistent formatting, not a rendered snippet.