taquba_workflow/error.rs
1use thiserror::Error;
2
3/// Errors returned by the runtime's submission and worker paths.
4#[derive(Debug, Error)]
5#[non_exhaustive]
6pub enum Error {
7 /// A step job is missing the [`crate::HEADER_RUN_ID`] header.
8 /// Permanent: a misconfigured job will not become valid on retry.
9 #[error("step job is missing header `{0}`")]
10 MissingHeader(&'static str),
11
12 /// A step job's [`crate::HEADER_STEP`] header is not a valid `u32`.
13 /// Permanent: header value won't change across retries.
14 #[error("step job has invalid `{header}` header `{value}`")]
15 InvalidStepHeader {
16 /// Header name.
17 header: &'static str,
18 /// Offending value.
19 value: String,
20 },
21
22 /// A submission included a user header starting with the reserved
23 /// `workflow.*` prefix. The runtime owns that prefix; submitters must use
24 /// any other key.
25 #[error("submission header `{0}` uses the reserved `workflow.*` prefix")]
26 ReservedHeaderInSubmit(String),
27
28 /// Submission was rejected because a run with the same `run_id` is already
29 /// active in this runtime's in-memory registry.
30 #[error("run `{0}` is already active in this runtime")]
31 DuplicateRun(String),
32
33 /// Underlying error from a Taquba queue operation.
34 #[error(transparent)]
35 Queue(#[from] taquba::Error),
36}
37
38impl Error {
39 /// True if this error should dead-letter the step rather than retry.
40 pub(crate) fn is_permanent(&self) -> bool {
41 matches!(
42 self,
43 Error::MissingHeader(_) | Error::InvalidStepHeader { .. }
44 )
45 }
46}
47
48/// Result alias used throughout the crate.
49pub type Result<T> = std::result::Result<T, Error>;