pub enum Error {
Configuration(String),
NotFound(String),
Serialization(String),
Unknown(Error),
}Expand description
Errors that an automaton can return
When an automaton executes its tasks, things can fail. Automatons might interact with external
resources or third-party APIs that are unreliable, the configuration might be wrong, or
something totally unexpected might happen. In these situations, automatons can abort their
execution and return an [Error].
§Example
The implementation of the error type is based on thiserror and anyhow. Unexpected errors can
easily be converted to an error by calling .context on the original error.
use std::io::ErrorKind;
use anyhow::Context;
use automatons::Error;
fn connect() -> Result<(), Error> {
let failure = Err(std::io::Error::new(ErrorKind::TimedOut, "connection timed out"));
let error = failure.context("failed to connect to API due to connection time out")?;
Ok(())
}anyhow: https://crates.io/crates/anyhow thiserror: https://crates.io/crates/thiserror
Variants§
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more