just/src/output_error.rs
Casey Rodarmor b2285ce0e0
Reform Parser (#509)
Just's first parser performed both parsing, i.e the transformation of a
token stream according to the language grammar, and a number of consistency
checks and analysis passes.

This made parsing and analysis quite complex, so this diff introduces a
new, much cleaner `Parser`, and moves existing analysis into a dedicated
`Analyzer`.
2019-11-07 10:55:15 -08:00

28 lines
853 B
Rust

use crate::common::*;
#[derive(Debug)]
pub(crate) enum OutputError {
/// Non-zero exit code
Code(i32),
/// IO error
Io(io::Error),
/// Terminated by signal
Signal(i32),
/// Unknown failure
Unknown,
/// Stdout not UTF-8
Utf8(std::str::Utf8Error),
}
impl Display for OutputError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
OutputError::Code(code) => write!(f, "Process exited with status code {}", code),
OutputError::Io(ref io_error) => write!(f, "Error executing process: {}", io_error),
OutputError::Signal(signal) => write!(f, "Process terminated by signal {}", signal),
OutputError::Unknown => write!(f, "Process experienced an unknown failure"),
OutputError::Utf8(ref err) => write!(f, "Could not convert process stdout to UTF-8: {}", err),
}
}
}