aboutsummaryrefslogtreecommitdiff
path: root/src/error
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-03-28 17:07:26 +0000
committerNerdyPepper <[email protected]>2019-03-28 17:07:26 +0000
commitbd20d7b591f9bfedf01403550c74a32268dc9984 (patch)
tree3b904bbd3f76c592329d64028f5240e349f678b5 /src/error
parentb717e52505c4a36424f118073c856f6e565cd7d4 (diff)
handler passes errors up the call stack
Diffstat (limited to 'src/error')
-rw-r--r--src/error/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/error/mod.rs b/src/error/mod.rs
index 14153fe..a269555 100644
--- a/src/error/mod.rs
+++ b/src/error/mod.rs
@@ -11,19 +11,19 @@ pub enum Math {
11 OutOfBounds, 11 OutOfBounds,
12} 12}
13 13
14pub fn handler(e: CalcError) { 14pub fn handler(e: CalcError) -> String {
15 match e { 15 match e {
16 CalcError::Math(math_err) => { 16 CalcError::Math(math_err) => {
17 match math_err { 17 match math_err {
18 Math::DivideByZero => println!("Math Error: Divide by zero error!"), 18 Math::DivideByZero => format!("Math Error: Divide by zero error!"),
19 Math::OutOfBounds => println!("Domain Error: Out of bounds!") 19 Math::OutOfBounds => format!("Domain Error: Out of bounds!")
20 } 20 }
21 }, 21 },
22 CalcError::Syntax(details) => { 22 CalcError::Syntax(details) => {
23 println!("Syntax Error: {}", details); 23 format!("Syntax Error: {}", details)
24 }, 24 },
25 CalcError::Parser(details) => { 25 CalcError::Parser(details) => {
26 println!("Parser Error: {}", details); 26 format!("Parser Error: {}", details)
27 } 27 }
28 } 28 }
29} 29}