Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,13 @@
public void run() {
progressDialog.dismiss();

processDeliveryItem(checkoutTransaction);
processDeliveryItem(checkoutTransaction, false);

Check warning on line 355 in app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java#L355

Added line #L355 was not covered by tests

checkoutTransaction.finish(SpanStatus.INTERNAL_ERROR);
}
});
} else {
processDeliveryItem(checkoutTransaction, true);

Check warning on line 361 in app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java#L361

Added line #L361 was not covered by tests
}
}

Expand All @@ -365,7 +367,7 @@
progressDialog.dismiss();
Sentry.captureException(e);

processDeliveryItem(checkoutTransaction);
processDeliveryItem(checkoutTransaction, false);

Check warning on line 370 in app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java#L370

Added line #L370 was not covered by tests
checkoutTransaction.finish(SpanStatus.INTERNAL_ERROR);
Log.e("checkout", "checkout failed");
}
Expand Down Expand Up @@ -410,22 +412,27 @@
return postBody;
}

private void processDeliveryItem(ITransaction checkoutTransaction) {
private void processDeliveryItem(ITransaction checkoutTransaction, boolean checkoutSuccess) {
Log.i("processDeliveryItem", "processDeliveryItem >>>");
ISpan processDeliverySpan = checkoutTransaction.startChild("task", "process delivery");

try {
throw new MainFragment.BackendAPIException("Failed to init delivery item workflow");
} catch (Exception e) {
Log.e("processDeliveryItem", e.getMessage());
processDeliverySpan.setThrowable(e);
processDeliverySpan.setStatus(SpanStatus.INTERNAL_ERROR);
Sentry.captureException(e);
if (!checkoutSuccess) {
// Checkout failed, log the error but don't throw an exception
Log.e("processDeliveryItem", "Cannot initialize delivery workflow due to checkout failure");
processDeliverySpan.setStatus(SpanStatus.INVALID_ARGUMENT);

Check warning on line 422 in app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java#L421-L422

Added lines #L421 - L422 were not covered by tests
} else {
// Proceed with delivery processing for successful checkout
try {
// Delivery initialization logic would go here
processDeliverySpan.setStatus(SpanStatus.OK);
} catch (Exception e) {
Log.e("processDeliveryItem", e.getMessage());
processDeliverySpan.setThrowable(e);
processDeliverySpan.setStatus(SpanStatus.INTERNAL_ERROR);
Sentry.captureException(e);
}

Check warning on line 433 in app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java#L427-L433

Added lines #L427 - L433 were not covered by tests
}

if (processDeliverySpan.getStatus() != SpanStatus.INTERNAL_ERROR) {
processDeliverySpan.setStatus(SpanStatus.OK);
}
processDeliverySpan.finish();
Log.i("processDeliveryItem", "<<< processDeliveryItem");
}
Expand Down