Skip to main content

ExecutorError

Struct ExecutorError 

Source
pub struct ExecutorError { /* private fields */ }
Expand description

An ordinary executor failure that becomes a business result.

The message is what the model is told: reef records Display as the tool’s output and the transcript keeps text, not types. So the message has to be complete on its own, and with_source does not extend it — attaching a source keeps the concrete failure as a value, for whoever inspects this error in process, and changes nothing about what the model reads.

That inspection is why the source exists. An executor almost always fails because something underneath it did — an I/O error, a transport failure, a timeout — and a composition layer that wraps executors, retries them, or classifies their failures needs the reason by its type rather than by matching on a sentence:

use std::io;
use reef_core::runtime::tool;

let failure = tool::ExecutorError::new("reading the manifest failed".to_owned())
    .with_source(io::Error::from(io::ErrorKind::NotFound));

// The message alone is what the model sees.
assert_eq!(failure.to_string(), "reading the manifest failed");

// The reason is still recoverable by its own type.
let cause = std::error::Error::source(&failure).expect("a source was attached");
let cause = cause.downcast_ref::<io::Error>().expect("the concrete cause");
assert_eq!(cause.kind(), io::ErrorKind::NotFound);

Implementations§

Source§

impl ExecutorError

Source

pub const fn new(message: String) -> Self

Creates an owned executor diagnostic.

Source

pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self

Retains the concrete failure this diagnostic is about.

Returned from Error::source, so the cause downcasts back to the caller’s own type. It does not affect the message, equality, or what the model is told; see the type’s own documentation for why.

Trait Implementations§

Source§

impl Clone for ExecutorError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutorError

Source§

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

Renders the message and then every link of the chain, each through Display.

Printing only the message would discard the reason with_source retains, which is the part a reader is usually after. Display rather than the link’s own Debug, because a cause is whatever an executor handed back: text this crate neither writes nor reviews, whose Display is the diagnostic the type is contracted to produce. This is the same rendering HookError uses.

Source§

impl Display for ExecutorError

Source§

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

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

impl Eq for ExecutorError

Source§

impl Error for ExecutorError

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 PartialEq for ExecutorError

Compares the diagnostic message and nothing else.

A retained source is an arbitrary third-party error with no equality of its own, so there is no answer to whether two of them are “the same”; comparing them by pointer would make two errors that say the same thing unequal, which is worse than not comparing them. The message is what this type is compared for — asserting on a diagnostic — so that is what equality means here.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.