Skip to content

fix: handle division by zero in calculator#144

Open
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-b65406f1
Open

fix: handle division by zero in calculator#144
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-b65406f1

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard clause in src/calculator.ts divide function that throws Error("Division by zero") when the divisor is zero
  • Added test cases in test/calculator.test.ts for normal division and division-by-zero error handling
  • All 5 tests pass

Assumptions

  • Throwing an Error is the appropriate way to handle division by zero (rather than returning Infinity, NaN, or a result object)
  • The error message "Division by zero" is descriptive enough for consumers

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.

0 participants