Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I added error handling for division by zero #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cjohns54
Copy link

@Cjohns54 Cjohns54 commented Nov 1, 2024

Updated the division methods to throw an
IllegalArgumentException if the divisor (b) is zero.
Adding error handling for division by zero is crucial to prevent runtime errors and ensure the program fails with a clear error message. This Improves code robustness and user experience.

@@ -3,11 +3,18 @@
public class Division {

public static final long division(int a, int b) {
if (b == 0) {
throw new IllegalArgumentException("Divisor cannot be zero.");
Copy link
Author

Choose a reason for hiding this comment

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

"I see you changed this to add erroring handling! Great job!"

Copy link
Author

Choose a reason for hiding this comment

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

This addresses the problem of poor error handling by adding this.

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.

1 participant