Skip to content

Fix ArithmeticException: divide by zero in MainActivity#211

Draft
cursor[bot] wants to merge 1 commit intomainfrom
arithmeticexception-divide-by-na0b6w
Draft

Fix ArithmeticException: divide by zero in MainActivity#211
cursor[bot] wants to merge 1 commit intomainfrom
arithmeticexception-divide-by-na0b6w

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 3, 2026

Problem

The app was crashing with an ArithmeticException: divide by zero when users clicked the division by zero button in MainActivity.

Solution

Fixed the unhandled ArithmeticException by:

  • Wrapping the division operation in a try-catch block
  • Capturing the exception using Sentry.captureException() for proper error tracking
  • Updated the comment to reflect that this is now a handled exception

Changes

  • Modified MainActivity.java to handle the ArithmeticException instead of letting it crash the app
  • The exception is still captured by Sentry for monitoring purposes
  • Follows the same error handling pattern used for other exceptions in the codebase

Testing

The fix follows the established pattern in the codebase (see lines 64-76 for ArrayIndexOutOfBoundsException handling).

Fixes ANDROID-EA

Open in Web Open in Cursor 

Fixes ANDROID-EA

- Wrapped the division by zero operation in a try-catch block
- Captured the exception using Sentry.captureException() instead of letting it crash
- Changed comment from 'Unhandled' to 'Handled' to reflect the fix
- Follows the same pattern as other handled exceptions in the code
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (814e302) to head (395d18f).

Files with missing lines Patch % Lines
...main/java/com/example/vu/android/MainActivity.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #211   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        864     867    +3     
  Branches      65      65           
=====================================
- Misses       864     867    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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