Skip to content

#578 Guard division by zero in Award calc#613

Merged
yegor256 merged 2 commits into
zerocracy:masterfrom
VasilevNStas:578-award-div-zero
Jul 17, 2026
Merged

#578 Guard division by zero in Award calc#613
yegor256 merged 2 commits into
zerocracy:masterfrom
VasilevNStas:578-award-div-zero

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Problem

When (div n 0) is evaluated in an award expression, Ruby raises ZeroDivisionError which is not caught and results in a 500-style crash with an unhelpful message.

Solution

Added a guard in the :div branch of BTerm#calc: if the divisor is zero, a descriptive Fbe::Error is raised instead of letting the raw ZeroDivisionError propagate.

Closes #578

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 plz review

@yegor256

Copy link
Copy Markdown
Member

@VasilevNStas no test?

@VasilevNStas VasilevNStas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256
Test added: test_division_by_zero_raises_error asserts that (div 10 0) raises Fbe::Error.

please re-review this PR

@yegor256
yegor256 merged commit 61544ec into zerocracy:master Jul 17, 2026
10 checks passed
@0crat

0crat commented Jul 17, 2026

Copy link
Copy Markdown

@VasilevNStas Thanks for the contribution! You've earned +20 points for this: +24 as a basis; -4 for too few (9) hits-of-code. Please, keep them coming. Your running score is +3428; don't forget to check your Zerocracy account too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Award calculation crashes with ZeroDivisionError on zero denominator

3 participants