Errors - ErrorKind to program exit code
This commit is contained in:
parent
a59dc21223
commit
36ac55d286
1 changed files with 10 additions and 0 deletions
|
@ -14,6 +14,16 @@ pub enum ErrorKind {
|
||||||
Runtime,
|
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 {
|
impl fmt::Display for ErrorKind {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str(match self {
|
f.write_str(match self {
|
||||||
|
|
Loading…
Reference in a new issue