#[non_exhaustive]pub enum WorkflowError {
CommandRejected {
reason: String,
},
InvalidState {
expected: String,
actual: String,
},
ValidationFailed {
message: String,
},
NotImplemented {
pid: u32,
},
Other {
message: String,
},
}Expand description
Reasons a workflow may refuse a command.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CommandRejected
The command is not valid for the process in its current state.
InvalidState
The command arrived when the process was in an unexpected state.
Fields
ValidationFailed
Domain validation of the command payload failed.
NotImplemented
The process identified by pid is registered in the PID router but has
no workflow implementation yet.
Callers should respond to the sender with a CONTRL/APERAK rejection. This variant is never a transient error — it indicates missing implementation and must not be retried.
Other
An unexpected error occurred inside the workflow handler.
Implementations§
Source§impl WorkflowError
impl WorkflowError
Sourcepub fn rejected(reason: impl Into<String>) -> Self
pub fn rejected(reason: impl Into<String>) -> Self
Construct a WorkflowError::CommandRejected with a formatted reason.
Sourcepub fn invalid_state(
expected: impl Into<String>,
actual: impl Into<String>,
) -> Self
pub fn invalid_state( expected: impl Into<String>, actual: impl Into<String>, ) -> Self
Construct a WorkflowError::InvalidState.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Construct a WorkflowError::ValidationFailed.
Sourcepub fn not_implemented(pid: u32) -> Self
pub fn not_implemented(pid: u32) -> Self
Construct a WorkflowError::NotImplemented for a given PID.
Use this to signal that the PID is routed but has no workflow implementation. Callers must respond with a CONTRL/APERAK rejection to the sender — this variant must never be silently discarded.
Sourcepub fn other(message: impl Into<String>) -> Self
pub fn other(message: impl Into<String>) -> Self
Construct a WorkflowError::Other.
Sourcepub fn is_rejected(&self) -> bool
pub fn is_rejected(&self) -> bool
Return true when this is a WorkflowError::CommandRejected.
Sourcepub fn is_invalid_state(&self) -> bool
pub fn is_invalid_state(&self) -> bool
Return true when this is a WorkflowError::InvalidState.
Sourcepub fn is_validation_failed(&self) -> bool
pub fn is_validation_failed(&self) -> bool
Return true when this is a WorkflowError::ValidationFailed.
Sourcepub fn is_not_implemented(&self) -> bool
pub fn is_not_implemented(&self) -> bool
Return true when this is a WorkflowError::NotImplemented.
This variant is never transient — callers must not retry.
Trait Implementations§
Source§impl Debug for WorkflowError
impl Debug for WorkflowError
Source§impl Display for WorkflowError
impl Display for WorkflowError
Source§impl Error for WorkflowError
impl Error for WorkflowError
1.30.0 · 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()