solti_runner/error.rs
1//! # Runner errors.
2//!
3//! [`RunnerError`] covers failures during runner selection and task construction.
4//!
5//! See [`Runner::build_task`](crate::Runner::build_task) and [`RunnerRouter::build`](crate::RunnerRouter::build)
6//! for the primary error sources.
7
8use thiserror::Error;
9
10/// Errors produced by runner operations.
11///
12/// ## Also
13///
14/// - [`Runner::build_task`](crate::Runner::build_task) — returns `Result<TaskRef, RunnerError>`.
15/// - [`RunnerRouter::build`](crate::RunnerRouter::build) — returns `NoRunner` when no runner matches.
16#[derive(Debug, Error)]
17pub enum RunnerError {
18 /// No registered runner can handle the given task kind.
19 #[error("no suitable runner for task kind: {0}")]
20 NoRunner(String),
21
22 /// Runner does not support the requested task kind.
23 #[error("unsupported task kind for runner '{runner}': {kind}")]
24 UnsupportedKind { runner: &'static str, kind: String },
25
26 /// Task specification is invalid for this runner.
27 #[error("invalid specification: {0}")]
28 InvalidSpec(String),
29
30 /// Internal runner error.
31 #[error("internal error: {0}")]
32 Internal(String),
33
34 /// Required field is missing from the task spec.
35 #[error("missing field: {0}")]
36 MissingField(&'static str),
37
38 /// I/O error during task setup.
39 #[error("io error: {0}")]
40 Io(String),
41}
42
43impl From<std::io::Error> for RunnerError {
44 fn from(e: std::io::Error) -> Self {
45 RunnerError::Io(e.to_string())
46 }
47}