tokio_process_tools/
error.rs1use std::borrow::Cow;
4use std::io;
5use std::time::Duration;
6use thiserror::Error;
7
8use crate::{CollectorError, InspectorError};
9
10#[derive(Debug, Error)]
12pub enum TerminationError {
13 #[error("Failed to send '{signal}' signal to process '{process_name}': {source}")]
15 SignallingFailed {
16 process_name: Cow<'static, str>,
18 source: io::Error,
20 signal: &'static str,
22 },
23
24 #[error(
26 "Failed to terminate process '{process_name}'. SIGINT failed: {sigint_error}. SIGTERM failed: {sigterm_error}. SIGKILL failed: {sigkill_error}"
27 )]
28 TerminationFailed {
29 process_name: Cow<'static, str>,
31 sigint_error: String,
33 sigterm_error: String,
35 #[source]
37 sigkill_error: io::Error,
38 },
39}
40
41#[derive(Debug, Error)]
43pub enum WaitError {
44 #[error("IO error occurred while waiting for process '{process_name}': {source}")]
46 IoError {
47 process_name: Cow<'static, str>,
49 #[source]
51 source: io::Error,
52 },
53
54 #[error("Process '{process_name}' did not complete within {timeout:?}")]
56 Timeout {
57 process_name: Cow<'static, str>,
59 timeout: Duration,
61 },
62
63 #[error("Could not terminate process: {0}")]
65 TerminationError(#[from] TerminationError),
66
67 #[error("Collector failed to collect output: {0}")]
69 CollectorFailed(#[from] CollectorError),
70}
71
72#[derive(Debug, Error)]
74pub enum SpawnError {
75 #[error("Failed to spawn process '{process_name}': {source}")]
77 SpawnFailed {
78 process_name: Cow<'static, str>,
80 #[source]
82 source: io::Error,
83 },
84}
85
86#[derive(Debug, Error)]
88pub enum OutputError {
89 #[error("Timed out after {timeout:?} waiting for output pattern on {stream_name}")]
91 Timeout {
92 stream_name: &'static str,
94 timeout: Duration,
96 },
97
98 #[error("Inspector failed: {0}")]
100 InspectorFailed(#[from] InspectorError),
101}