Skip to main content

petr_dispatch/
error.rs

1use thiserror::Error;
2
3/// Result type for operation dispatch.
4pub type DispatchResult<T> = Result<T, DispatchError>;
5
6/// Errors returned by selector dispatch.
7#[derive(Debug, Error, Clone, PartialEq, Eq)]
8pub enum DispatchError {
9    /// No operation was registered for the selector.
10    #[error("operation not found for selector {0:#04x}")]
11    OperationNotFound(u8),
12
13    /// Input was not valid for the selected operation.
14    #[error("invalid input: {0}")]
15    InvalidInput(String),
16
17    /// TOML config declared an operation type this crate does not know.
18    #[error("unknown operation type: {0}")]
19    UnknownOperationType(String),
20
21    /// TOML config omitted a required parameter.
22    #[error("missing parameter `{param}` for operation `{op}`")]
23    MissingParam { op: String, param: &'static str },
24
25    /// Program counter stepped out of the chain.
26    #[error("invalid continuation index {0}")]
27    InvalidContinuation(usize),
28}