Skip to main content

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