scientific_workflow/runtime/error.rs
1//! Active runtime failures.
2
3use std::path::PathBuf;
4use std::time::Duration;
5
6use thiserror::Error;
7
8/// A failure after an immutable study passed preflight.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum RuntimeError {
12 /// Interactive UI requested cooperative cancellation of the execution.
13 #[error("workflow execution was cancelled by the user")]
14 ExecutionCancelled,
15
16 /// Runtime could not create an inferred execution or replicate scope.
17 #[error("failed to create inferred output scope `{path}`")]
18 OutputScope {
19 /// Intended output location.
20 path: PathBuf,
21 /// Underlying filesystem failure.
22 #[source]
23 source: std::io::Error,
24 },
25
26 /// An execution-unit or program invocation returned an application, process, state,
27 /// observation, or persistence error.
28 #[error("task `{task}` failed: {source}")]
29 Task {
30 /// Inferred task identity.
31 task: String,
32 /// Original task failure.
33 #[source]
34 source: Box<dyn std::error::Error + Send + Sync + 'static>,
35 },
36
37 /// A task invocation panicked. Runtime fails any active member recording
38 /// before reporting this stable task identity.
39 #[error("task `{task}` panicked")]
40 TaskPanicked {
41 /// Inferred task identity.
42 task: String,
43 },
44
45 /// A task exceeded its timeout; execution units stop cooperatively while external
46 /// programs are terminated by Runtime.
47 #[error("task `{task}` exceeded its timeout of {timeout:?}")]
48 TaskTimedOut {
49 /// Inferred task identity.
50 task: String,
51 /// Effective timeout.
52 timeout: Duration,
53 },
54
55 /// A running task stopped because Runtime cancelled it. Execution units stop
56 /// cooperatively while external programs are terminated.
57 #[error("task `{task}` was cancelled")]
58 TaskCancelled {
59 /// Inferred task identity.
60 task: String,
61 },
62
63 /// A phase exceeded its timeout. Its active execution-unit tasks stop cooperatively
64 /// and its active external programs are terminated.
65 #[error("phase `{phase}` exceeded its timeout of {timeout:?}")]
66 PhaseTimedOut {
67 /// Stable phase key.
68 phase: String,
69 /// Effective timeout.
70 timeout: Duration,
71 },
72
73 /// Runtime could not start an operating-system worker thread.
74 #[error("failed to start runtime worker for `{scope}`")]
75 StartWorker {
76 /// Task or replicate identity.
77 scope: String,
78 /// Thread creation failure.
79 #[source]
80 source: std::io::Error,
81 },
82
83 /// A replicate worker panicked.
84 #[error("replicate {index} panicked")]
85 ReplicatePanicked {
86 /// Zero-based replicate index.
87 index: u64,
88 },
89
90 /// A replicate failed under either failure policy.
91 #[error("replicate {index} failed: {source}")]
92 Replicate {
93 /// Zero-based failed replicate index.
94 index: u64,
95 /// Original runtime failure.
96 #[source]
97 source: Box<RuntimeError>,
98 },
99}