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 /// A model 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 in its runtime worker.
38 #[error("task `{task}` panicked")]
39 TaskPanicked {
40 /// Inferred task identity.
41 task: String,
42 },
43
44 /// A task exceeded its timeout; models stop cooperatively while external
45 /// programs are terminated by Runtime.
46 #[error("task `{task}` exceeded its timeout of {timeout:?}")]
47 TaskTimedOut {
48 /// Inferred task identity.
49 task: String,
50 /// Effective timeout.
51 timeout: Duration,
52 },
53
54 /// A running task stopped because Runtime cancelled it. Models stop
55 /// cooperatively while external programs are terminated.
56 #[error("task `{task}` was cancelled")]
57 TaskCancelled {
58 /// Inferred task identity.
59 task: String,
60 },
61
62 /// A phase exceeded its timeout. Its active model tasks stop cooperatively
63 /// and its active external programs are terminated.
64 #[error("phase `{phase}` exceeded its timeout of {timeout:?}")]
65 PhaseTimedOut {
66 /// Stable phase key.
67 phase: String,
68 /// Effective timeout.
69 timeout: Duration,
70 },
71
72 /// Runtime could not start an operating-system worker thread.
73 #[error("failed to start runtime worker for `{scope}`")]
74 StartWorker {
75 /// Task or replicate identity.
76 scope: String,
77 /// Thread creation failure.
78 #[source]
79 source: std::io::Error,
80 },
81
82 /// A replicate worker panicked.
83 #[error("replicate {index} panicked")]
84 ReplicatePanicked {
85 /// Zero-based replicate index.
86 index: u64,
87 },
88
89 /// At least one replicate failed under a finish-all policy.
90 #[error("replicate {index} failed: {source}")]
91 Replicate {
92 /// Zero-based failed replicate index.
93 index: u64,
94 /// Original runtime failure.
95 #[source]
96 source: Box<RuntimeError>,
97 },
98}