modewise_pipeline/
error.rs1use thiserror::Error;
2
3use crate::{ArtifactKind, StoreError};
4
5#[derive(Debug, Error)]
6pub enum PipelineError {
7 #[error("cannot read pipeline spec: {0}")]
8 Spec(String),
9 #[error("step id {0:?} is invalid: ids must be non-empty and must not contain '.'")]
10 InvalidStepId(String),
11 #[error("name {0:?} is used more than once")]
12 DuplicateName(String),
13 #[error("step {step:?}: unknown operation {op:?}")]
14 UnknownOperation { step: String, op: String },
15 #[error("step {step:?}: {message}")]
16 InvalidParams { step: String, message: String },
17 #[error("step {step:?}: {message}")]
18 InvalidInputs { step: String, message: String },
19 #[error("step {step:?}: input {reference:?} refers to nothing")]
20 UnknownReference { step: String, reference: String },
21 #[error(
22 "step {step:?}: port {port:?} needs {}, but {reference:?} gives {found}",
23 kinds(expected)
24 )]
25 KindMismatch {
26 step: String,
27 port: String,
28 reference: String,
29 expected: Vec<ArtifactKind>,
30 found: ArtifactKind,
31 },
32 #[error("step {0:?} has keep = false but no step uses its output, so it would be lost")]
33 UnusedTransient(String),
34 #[error("steps depend on each other in a cycle: {0:?}")]
35 Cycle(Vec<String>),
36 #[error("pipeline input {0:?} was not provided")]
37 MissingInput(String),
38 #[error("pipeline input {name:?} must be {expected}, got {found}")]
39 InputKind {
40 name: String,
41 expected: ArtifactKind,
42 found: ArtifactKind,
43 },
44 #[error("{0:?} is not a declared pipeline input")]
45 UnexpectedInput(String),
46 #[error("step {step:?} failed: {message}")]
47 StepFailed { step: String, message: String },
48 #[error(transparent)]
49 Store(#[from] StoreError),
50}
51
52fn kinds(kinds: &[ArtifactKind]) -> String {
53 kinds
54 .iter()
55 .map(ToString::to_string)
56 .collect::<Vec<_>>()
57 .join(" or ")
58}