From 5b7f9c312d840b08848d78869ebd4b1d4702b79c Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Sat, 27 Apr 2019 21:28:15 +0530 Subject: add error handling for radix fmt --- src/error/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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 { pub enum Math { DivideByZero, OutOfBounds, + UnknownBase } pub fn handler(e: CalcError) -> String { @@ -20,7 +21,8 @@ pub fn handler(e: CalcError) -> String { CalcError::Math(math_err) => { match math_err { Math::DivideByZero => format!("Math Error: Divide by zero error!"), - Math::OutOfBounds => format!("Domain Error: Out of bounds!") + Math::OutOfBounds => format!("Domain Error: Out of bounds!"), + Math::UnknownBase => format!("Base too large! Accepted ranges: 0 - 36") } }, CalcError::Syntax(details) => { -- cgit v1.2.3