Error handling for modulo operation
Add zero check for denominator as it could result in divide by zero
exception.
Tested:
Successfully able to handle the zero condition
Change-Id: I400b03db1fbf81afdaa92243fa4af48d19807466
Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com>
diff --git a/src/expression.cpp b/src/expression.cpp
index c859800..377bdd8 100644
--- a/src/expression.cpp
+++ b/src/expression.cpp
@@ -75,6 +75,11 @@
}
case Operation::modulo:
{
+ if (b == 0)
+ {
+ throw std::runtime_error(
+ "Math error: Attempted to divide by Zero\n");
+ }
return a % b;
}