Skip to main content

Error

Enum Error 

Source
pub enum Error {
    Io(Error),
    State(Error),
    Provider {
        kind: ProviderErrorKind,
        status: Option<u16>,
        retry_after: Option<Duration>,
        message: String,
    },
    Config(String),
    Sandbox {
        reason: String,
    },
    Refused {
        act: String,
        target: String,
        rule: Option<String>,
        layer: Option<String>,
    },
    Mcp {
        server: String,
        reason: String,
    },
    Resume {
        reason: String,
    },
}
Expand description

Errors io-harness can return from a run.

The variants are separate because the response to each is separate — a refusal is not a malfunction, a bad checkpoint is not a bad key, and only one arm here is ever worth retrying. This is the match a caller writes around an entry point:

use io_harness::Error;

match failure {
    // The policy said no. Nothing happened and nothing is broken: either
    // widen the rule that refused it, or accept the refusal. The rule and
    // layer are carried so the operator knows which line of config to edit.
    Error::Refused { act, target, rule, layer } => format!(
        "{act} {target} refused by {} in layer {}",
        rule.unwrap_or_else(|| "the tier default".into()),
        layer.unwrap_or_else(|| "-".into()),
    ),
    // The checkpoint could not be honoured — newer format, missing run, or a
    // run started under a policy this resume would have silently dropped.
    // Never retried in a loop: re-resume the way the message names.
    Error::Resume { reason } => format!("resume refused: {reason}"),
    // Operator error, raised before the provider is called once. Fail the
    // job; a second attempt reaches the same missing key or duplicate tool.
    Error::Config(message) => format!("fix the configuration: {message}"),
    // The tool server never came up. The run fails rather than quietly
    // proceeding without a capability it was told it had.
    Error::Mcp { server, reason } => format!("server {server} did not start: {reason}"),
    // The gate never ran the code, as opposed to running it and failing it.
    Error::Sandbox { reason } => format!("verification never executed: {reason}"),
    // The one arm where another attempt is a real option — and only for some
    // kinds; see `ProviderErrorKind::is_retryable`.
    Error::Provider { kind, message, .. } if kind.is_retryable() => format!("retry: {message}"),
    other => other.to_string(),
}

Variants§

§

Io(Error)

A filesystem tool operation failed.

§

State(Error)

The state store (rusqlite) failed.

§

Provider

The provider request or its streamed response failed.

ProviderErrorKind is what a caller branches on; status and retry_after are kept rather than folded into the message so a retry can honour what the server actually said.

Fields

§kind: ProviderErrorKind

Why the call failed, and whether retrying is worth it.

§status: Option<u16>

The HTTP status, when the failure had one.

§retry_after: Option<Duration>

The server’s Retry-After, when it sent one.

§message: String

What the provider or the transport reported.

§

Config(String)

Configuration was missing or invalid (e.g. no API key).

§

Sandbox

The sandbox failed to start (e.g. the backend or the program could not be spawned). Typed separately from Error::Io so a calling agent can tell “the sandbox never ran the code” apart from “the code ran and failed”, and adapt — one failed child does not take down its siblings or the tree.

Fields

§reason: String

Why the sandbox could not start the command.

§

Refused

The permission policy refused the action. Typed separately from Error::Config so a refusal is distinguishable from a malfunction — a verification that was refused is not a verification that ran and failed, and the model is told the difference.

Fields

§act: String

The action attempted.

§target: String

The path or binary it targeted.

§rule: Option<String>

The glob that refused it, when a rule rather than a default did.

§layer: Option<String>

The layer that rule came from.

§

Mcp

An MCP server could not be reached or set up. Typed separately from Error::Provider so a caller can tell “the model call failed” from “the tool server the operator configured never came up” — the second is a configuration problem, and the run fails on it rather than quietly proceeding without a capability it was told it had.

Failures during a call — a timeout, a dead transport, a tool reporting its own error — are not this. They come back to the model as observations it can adapt to, like a refused path or a bad regex.

Fields

§server: String

The configured server’s id.

§reason: String

What went wrong.

§

Resume

A durable run could not be resumed from its checkpoint — the checkpoint format is newer than this binary supports, the run row is missing or corrupt, or the run has already finished. Typed separately so a caller handles a bad-checkpoint resume as a recoverable error instead of a panic or a silent half-resume. A partially written (crashed mid-commit) step is never surfaced here: the transaction rolls it back, so resume always sees the prior consistent checkpoint, not a torn one.

Fields

§reason: String

Why the run could not be resumed.

Implementations§

Source§

impl Error

Source

pub fn provider(kind: ProviderErrorKind, message: impl Into<String>) -> Self

A provider failure of kind carrying no HTTP status — the request never completed, or the response could not be read.

Source

pub fn provider_transport(message: impl Into<String>) -> Self

The request never completed: connection refused, DNS, TLS, a mid-stream byte error.

Source

pub fn provider_malformed(message: impl Into<String>) -> Self

The response arrived and nothing in it could be read.

Source

pub fn provider_status( status: u16, retry_after: Option<Duration>, message: impl Into<String>, ) -> Self

A non-success HTTP status, with the kind derived once by ProviderErrorKind::from_status so no provider can classify it differently.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Every reqwest failure the crate sees is a provider call that did not complete, so the timeout/transport split is decided here once instead of at each of the four call sites (three providers plus the shared SSE reader).

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Separable for T
where T: Display,

Source§

fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String

Adds separators according to the given SeparatorPolicy. Read more
Source§

fn separate_with_commas(&self) -> String

Inserts a comma every three digits from the right. Read more
Source§

fn separate_with_spaces(&self) -> String

Inserts a space every three digits from the right. Read more
Source§

fn separate_with_dots(&self) -> String

Inserts a period every three digits from the right. Read more
Source§

fn separate_with_underscores(&self) -> String

Inserts an underscore every three digits from the right. Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more