Skip to main content

systemprompt_loader/subprocess/
error.rs

1//! Typed failures of process supervision.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6/// Why a supervision call could not establish or change a process's state.
7#[derive(Debug, thiserror::Error)]
8pub enum SupervisionError {
9    #[error("pid {pid} is not a signalable process id")]
10    NotSignalable { pid: u32 },
11
12    #[error("failed to send {signal} to pid {pid}")]
13    Signal {
14        pid: u32,
15        signal: &'static str,
16        #[source]
17        source: std::io::Error,
18    },
19
20    #[error("pid {pid} was still running after a forced kill")]
21    Survived { pid: u32 },
22
23    #[error("failed to run `{tool}`")]
24    Tool {
25        tool: &'static str,
26        #[source]
27        source: std::io::Error,
28    },
29
30    #[error("`{tool}` failed with {status}")]
31    ToolFailed {
32        tool: &'static str,
33        status: std::process::ExitStatus,
34    },
35
36    #[error("process supervision is not supported on this platform")]
37    Unsupported,
38
39    #[error("blocking supervision task did not complete")]
40    Join(#[from] tokio::task::JoinError),
41}