diff --git a/src/errors.rs b/src/errors.rs index 4efe60b..f117993 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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 {