aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-04-27 16:58:15 +0100
committerNerdyPepper <[email protected]>2019-04-27 16:58:15 +0100
commit5b7f9c312d840b08848d78869ebd4b1d4702b79c (patch)
tree9b1a9f37ac5a19860bf930ca72070a87afe7bea3
parent7429da2a22bcdc6efdf9e5d5a207747b40ff62a1 (diff)
add error handling for radix fmt
-rw-r--r--src/error/mod.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs
index 649ef08..9ac6816 100644
--- a/src/error/mod.rs
+++ b/src/error/mod.rs
@@ -13,6 +13,7 @@ pub enum CalcError {
13pub enum Math { 13pub enum Math {
14 DivideByZero, 14 DivideByZero,
15 OutOfBounds, 15 OutOfBounds,
16 UnknownBase
16} 17}
17 18
18pub fn handler(e: CalcError) -> String { 19pub fn handler(e: CalcError) -> String {
@@ -20,7 +21,8 @@ pub fn handler(e: CalcError) -> String {
20 CalcError::Math(math_err) => { 21 CalcError::Math(math_err) => {
21 match math_err { 22 match math_err {
22 Math::DivideByZero => format!("Math Error: Divide by zero error!"), 23 Math::DivideByZero => format!("Math Error: Divide by zero error!"),
23 Math::OutOfBounds => format!("Domain Error: Out of bounds!") 24 Math::OutOfBounds => format!("Domain Error: Out of bounds!"),
25 Math::UnknownBase => format!("Base too large! Accepted ranges: 0 - 36")
24 } 26 }
25 }, 27 },
26 CalcError::Syntax(details) => { 28 CalcError::Syntax(details) => {