Skip to content

Commit

Permalink
Merge pull request #2507 from sopel-irc/calc-error-handler
Browse files Browse the repository at this point in the history
calc: gracefully handle `ExpressionEvaluator.Error`
  • Loading branch information
dgw committed Sep 27, 2023
2 parents 953f2eb + a12e799 commit 8c3e533
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sopel/modules/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def c(bot, trigger):
try:
result = eval_equation(eqn)
result = "{:.10g}".format(result)
except eval_equation.Error as err:
bot.reply("Can't process expression: {}".format(str(err)))
return
except ZeroDivisionError:
bot.reply('Division by zero is not supported in this universe.')
return
Expand Down

0 comments on commit 8c3e533

Please sign in to comment.