aboutsummaryrefslogtreecommitdiff
path: root/src/error
diff options
context:
space:
mode:
Diffstat (limited to 'src/error')
-rw-r--r--src/error/mod.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs
index 9ac6816..ec2b555 100644
--- a/src/error/mod.rs
+++ b/src/error/mod.rs
@@ -13,23 +13,17 @@ pub enum CalcError {
13pub enum Math { 13pub enum Math {
14 DivideByZero, 14 DivideByZero,
15 OutOfBounds, 15 OutOfBounds,
16 UnknownBase 16 UnknownBase,
17} 17}
18 18
19pub fn handler(e: CalcError) -> String { 19pub fn handler(e: CalcError) -> String {
20 match e { 20 match e {
21 CalcError::Math(math_err) => { 21 CalcError::Math(math_err) => match math_err {
22 match math_err { 22 Math::DivideByZero => "Math Error: Divide by zero error!".to_string(),
23 Math::DivideByZero => format!("Math Error: Divide by zero error!"), 23 Math::OutOfBounds => "Domain Error: Out of bounds!".to_string(),
24 Math::OutOfBounds => format!("Domain Error: Out of bounds!"), 24 Math::UnknownBase => "Base too large! Accepted ranges: 0 - 36".to_string(),
25 Math::UnknownBase => format!("Base too large! Accepted ranges: 0 - 36")
26 }
27 }, 25 },
28 CalcError::Syntax(details) => { 26 CalcError::Syntax(details) => format!("Syntax Error: {}", details),
29 format!("Syntax Error: {}", details) 27 CalcError::Parser(details) => format!("Parser Error: {}", details),
30 },
31 CalcError::Parser(details) => {
32 format!("Parser Error: {}", details)
33 }
34 } 28 }
35} 29}