command_error/
wait_error.rs1use std::fmt::Debug;
2use std::fmt::Display;
3
4#[cfg(doc)]
5use crate::ChildExt;
6use crate::CommandDisplay;
7#[cfg(feature = "miette")]
8use miette::Diagnostic;
9
10pub struct WaitError {
34 pub(crate) command: Box<dyn CommandDisplay + Send + Sync>,
35 pub(crate) inner: std::io::Error,
36}
37
38impl WaitError {
39 pub fn new(command: Box<dyn CommandDisplay + Send + Sync>, inner: std::io::Error) -> Self {
41 Self { command, inner }
42 }
43}
44
45impl Debug for WaitError {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 f.debug_struct("WaitError")
48 .field("program", &self.command.program())
49 .field("inner", &self.inner)
50 .finish()
51 }
52}
53
54impl Display for WaitError {
55 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56 write!(
57 f,
58 "Failed to wait for `{}`: {}",
59 self.command.program_quoted(),
60 self.inner
61 )
62 }
63}
64
65impl std::error::Error for WaitError {}
66
67#[cfg(feature = "miette")]
68impl Diagnostic for WaitError {}
69
70#[cfg(test)]
71mod tests {
72 use super::*;
73 use static_assertions::assert_impl_all;
74
75 assert_impl_all!(WaitError: Send, Sync);
76}