Fix hardcoded exception in processDeliveryItem method#206
Draft
cursor[bot] wants to merge 1 commit intomainfrom
Draft
Fix hardcoded exception in processDeliveryItem method#206cursor[bot] wants to merge 1 commit intomainfrom
cursor[bot] wants to merge 1 commit intomainfrom
Conversation
Fixes ANDROID-DN Removed the deliberate throw statement on line 427 that was causing MainFragment$BackendAPIException when checkout HTTP response fails. The processDeliveryItem() method is called on failed checkout responses to handle delivery workflow initialization. Previously, it immediately threw a hardcoded exception instead of properly handling the failure case. Now the method: - Logs a warning that checkout failed and delivery workflow cannot be initialized - Sets the span status to INTERNAL_ERROR appropriately - Completes without throwing an unnecessary exception - Still captures any genuine exceptions that may occur This allows the Android app to gracefully handle HTTP 500 errors from the backend (e.g., due to inventory validation failures) without crashing with a hardcoded exception.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 16 16
Lines 864 866 +2
Branches 65 65
=====================================
- Misses 864 866 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ANDROID-DN
This PR resolves the issue where a hardcoded
MainFragment$BackendAPIExceptionwas being thrown in theprocessDeliveryItem()method when the checkout API fails.Problem
When the Android app's checkout flow encounters an HTTP 500 error (e.g., due to backend inventory validation failures), the app enters the failure handling path and calls
processDeliveryItem(). However, instead of properly handling the delivery workflow initialization, the method was deliberately throwing a hardcoded exception on line 427.Root Cause Flow:
/checkoutendpointprocessDeliveryItem()which throws hardcoded exceptionBackendAPIExceptionto be thrownSolution
Removed the deliberate
throwstatement and replaced it with proper error handling:INTERNAL_ERRORappropriatelyChanges
Modified
app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java:throw new MainFragment.BackendAPIException("Failed to init delivery workflow");Testing
The fix ensures that when checkout fails: