1use runifold_core::{JournalError, RunError};
2use thiserror::Error;
3
4#[derive(Clone, Debug, Eq, PartialEq)]
6#[non_exhaustive]
7pub enum EffectExecutorErrorKind {
8 CapabilityDenied,
10 IdempotencyConflict,
12 Ambiguous,
14 Store,
16 Observability,
18 Handler,
20 Cancelled,
22 DeadlineExceeded,
24 Protocol,
26}
27
28#[derive(Clone, Debug, Error, PartialEq)]
30#[error("{kind:?}: {message}")]
31pub struct EffectExecutorError {
32 pub kind: EffectExecutorErrorKind,
34 pub message: String,
36 #[source]
38 pub source_error: Option<RunError>,
39}
40
41impl EffectExecutorError {
42 pub fn new(kind: EffectExecutorErrorKind, message: impl Into<String>) -> Self {
44 Self {
45 kind,
46 message: message.into(),
47 source_error: None,
48 }
49 }
50
51 pub(crate) fn handler(error: RunError) -> Self {
52 Self {
53 kind: EffectExecutorErrorKind::Handler,
54 message: error.to_string(),
55 source_error: Some(error),
56 }
57 }
58}
59
60impl From<JournalError> for EffectExecutorError {
61 fn from(error: JournalError) -> Self {
62 Self::new(EffectExecutorErrorKind::Observability, error.to_string())
63 }
64}