Error handling for division operation
Checked for the denominator and handle the case if denominator is zero.
Tested:
Successfully able to handle the zero condition
Change-Id: I11d4b6dbc9e49034049feacc011b0f9a1a044325
Signed-off-by: V-Sanjana <sanjana.v@intel.com>
diff --git a/src/expression.cpp b/src/expression.cpp
index 50fcbe3..c859800 100644
--- a/src/expression.cpp
+++ b/src/expression.cpp
@@ -66,6 +66,11 @@
}
case Operation::division:
{
+ if (b == 0)
+ {
+ throw std::runtime_error(
+ "Math error: Attempted to divide by Zero\n");
+ }
return a / b;
}
case Operation::modulo: