1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Typed errors for the workloop engine services.
use aion_core::{WorkflowId, WorkloopSpecError};
use aion_store::StoreError;
use crate::durability::DurabilityError;
/// Errors produced by the workloop services.
#[derive(thiserror::Error, Debug)]
pub enum WorkloopError {
/// A declaration was invalid at the engine boundary (no assumed defaults:
/// cadence, tolerance, and retention are declared or refused).
#[error("workloop declaration refused: {0}")]
Spec(#[from] WorkloopSpecError),
/// The workloop store refused or failed an operation.
#[error("workloop store failure: {0}")]
Store(#[from] StoreError),
/// The single-Recorder append path failed.
#[error("workloop record failure: {0}")]
Durability(#[from] DurabilityError),
/// A loop id was expected to be registered and was not.
#[error("workloop {loop_id} is not registered")]
NotRegistered {
/// The unregistered loop.
loop_id: WorkflowId,
},
/// A loop was already registered under this id.
#[error("workloop {loop_id} is already registered")]
AlreadyRegistered {
/// The already-registered loop.
loop_id: WorkflowId,
},
/// The sweep interval was zero: the sweeper's clock is a declared value,
/// never defaulted, and a zero interval is a busy-spin, not a cadence.
#[error("workloop sweep interval must be greater than zero")]
ZeroSweepInterval,
/// A declared duration could not be represented on the engine clock.
#[error("declared duration is not representable: {reason}")]
UnrepresentableDuration {
/// What overflowed.
reason: String,
},
/// A health sample named an invariant the loop never declared.
#[error("health sample names undeclared invariant `{invariant}` on loop {loop_id}")]
UndeclaredInvariant {
/// The loop the sample was fed to.
loop_id: WorkflowId,
/// The undeclared invariant name.
invariant: String,
},
/// The engine seam refused an operation (recording, waking, spawning).
#[error("engine seam failure: {reason}")]
Engine {
/// Human-readable seam failure reason.
reason: String,
},
}
impl From<WorkloopError> for crate::error::EngineError {
fn from(error: WorkloopError) -> Self {
Self::Runtime {
reason: error.to_string(),
}
}
}