diff options
Diffstat (limited to 'src/backends/run_error.rs')
-rw-r--r-- | src/backends/run_error.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/backends/run_error.rs b/src/backends/run_error.rs new file mode 100644 index 0000000..68f0495 --- /dev/null +++ b/src/backends/run_error.rs @@ -0,0 +1,38 @@ +use crate::wait::WaitError; +use std::io::Error as IoError; + +#[derive(Debug)] +pub enum RunError { + IoError(std::io::Error), + WaitError(WaitError) +} + +impl From<IoError> for RunError { + fn from(err: IoError) -> Self { + RunError::IoError(err) + } +} + +impl From<WaitError> for RunError { + fn from(err: WaitError) -> Self { + RunError::WaitError(err) + } +} + +impl std::fmt::Display for RunError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match &*self { + RunError::IoError(e) => e.fmt(f), + RunError::WaitError(e) => e.fmt(f) + } + } +} + +impl std::error::Error for RunError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + RunError::IoError(ref e) => Some(e), + RunError::WaitError(ref e) => Some(e) + } + } +}
\ No newline at end of file |