#[non_exhaustive]pub enum Error {
Spawn(BoxError),
Install(BoxError),
Login(BoxError),
Cancel(BoxError),
Other(String),
}Expand description
Why a Harness operation failed. Returned by install / run /
login / RunControl::cancel so a consumer can branch on the kind of
failure — offer install vs sign-in vs surface the message — instead of
string-matching.
Each category carries the real underlying error as a source (via the
BoxError field), so a consumer that wants more than the category can
walk .source() or downcast_ref::<cli_stream::StreamError>() /
::<bob_rs::BobError>(). The Display still flattens the source into the
message ("failed to start the agent: <source>"), so a consumer that just
stringifies at a boundary (e.g. a Tauri command’s .to_string()) gets the
same full message as before. #[non_exhaustive] so adding a variant later
isn’t a breaking change.
use harness::{Error, StreamError};
use std::error::Error as _; // for `.source()`, without shadowing `harness::Error`
// Box any typed source under a category constructor:
let err = Error::spawn(StreamError::PipeNotCaptured { stream: "stdout" });
// Stringifying at a boundary flattens the source into the message
// (so a Tauri command's `.to_string()` keeps its full text)…
assert!(err.to_string().starts_with("failed to start the agent: "));
// …while the real typed cause stays reachable for a consumer that wants
// to branch on it rather than parse a string.
let source = err.source().expect("Command carries a source");
assert!(source.downcast_ref::<StreamError>().is_some());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Spawn(BoxError)
The harness’s CLI couldn’t be started — not installed, not on PATH,
or an OS-level spawn failure.
Install(BoxError)
A one-time install step failed.
Login(BoxError)
Interactive sign-in failed.
Cancel(BoxError)
Cancelling an in-flight run failed.
Other(String)
Any other adapter/runtime failure (e.g. a backend SDK error that doesn’t map onto the cases above). Carries a message rather than a source — it’s the catch-all when there’s nothing typed to preserve.
Implementations§
Source§impl Error
impl Error
Sourcepub fn spawn(source: impl Into<BoxError>) -> Self
pub fn spawn(source: impl Into<BoxError>) -> Self
Categorize a source error as a Spawn failure.
Accepts anything boxable — a typed StreamError/BobError, or a
String/&str for adapters with nothing typed to carry.
Sourcepub fn install(source: impl Into<BoxError>) -> Self
pub fn install(source: impl Into<BoxError>) -> Self
Categorize a source error as an Install failure.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()