diff options
author | NerdyPepper <[email protected]> | 2019-04-27 16:58:15 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-04-27 16:58:15 +0100 |
commit | 5b7f9c312d840b08848d78869ebd4b1d4702b79c (patch) | |
tree | 9b1a9f37ac5a19860bf930ca72070a87afe7bea3 /src | |
parent | 7429da2a22bcdc6efdf9e5d5a207747b40ff62a1 (diff) |
add error handling for radix fmt
Diffstat (limited to 'src')
-rw-r--r-- | src/error/mod.rs | 4 |
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 { | |||
13 | pub enum Math { | 13 | pub enum Math { |
14 | DivideByZero, | 14 | DivideByZero, |
15 | OutOfBounds, | 15 | OutOfBounds, |
16 | UnknownBase | ||
16 | } | 17 | } |
17 | 18 | ||
18 | pub fn handler(e: CalcError) -> String { | 19 | pub 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) => { |