Errors - ErrorKind to program exit code

This commit is contained in:
Emmanuel BENOîT 2023-01-03 22:44:48 +01:00
parent a59dc21223
commit 36ac55d286

View file

@ -14,6 +14,16 @@ pub enum ErrorKind {
Runtime,
}
impl ErrorKind {
/// Program exit code based on the kind of error.
pub fn exit_code(self) -> u8 {
match self {
ErrorKind::Scan | ErrorKind::Parse => 65,
ErrorKind::Runtime => 70,
}
}
}
impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {