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
impl ExecutorError
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
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
impl Clone for ExecutorError
Source§impl Debug for ExecutorError
impl Debug for ExecutorError
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
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
impl Display for ExecutorError
impl Eq for ExecutorError
Source§impl Error for ExecutorError
impl Error for ExecutorError
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()
Source§impl PartialEq for ExecutorError
Compares the diagnostic message and nothing else.
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.