From 36ac55d286a289eafe20fba212152049985f61ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Tue, 3 Jan 2023 22:44:48 +0100
Subject: [PATCH] Errors - ErrorKind to program exit code

---
 src/errors.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

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 {