diff --git a/app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java b/app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java index e871b43..4c113b3 100644 --- a/app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java +++ b/app/src/main/java/com/example/vu/android/empowerplant/MainFragment.java @@ -365,15 +365,20 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO progressDialog.dismiss(); boolean success = response.isSuccessful(); response.close(); - if (!success) { + if (success) { + runOnUiThread(new Runnable() { + @Override + public void run() { + processDeliveryItem(checkoutTransaction); + checkoutTransaction.finish(SpanStatus.OK); + } + }); + } else { Log.w("checkout", "response failed"); runOnUiThread(new Runnable() { @Override public void run() { progressDialog.dismiss(); - - processDeliveryItem(checkoutTransaction); - checkoutTransaction.finish(SpanStatus.INTERNAL_ERROR); } }); @@ -384,8 +389,6 @@ public void run() { public void onFailure(@NotNull Call call, @NotNull IOException e) { progressDialog.dismiss(); Sentry.captureException(e); - - processDeliveryItem(checkoutTransaction); checkoutTransaction.finish(SpanStatus.INTERNAL_ERROR); Log.e("checkout", "checkout failed"); } @@ -434,18 +437,7 @@ private void processDeliveryItem(ITransaction checkoutTransaction) { Log.i("processDeliveryItem", "processDeliveryItem >>>"); ISpan processDeliverySpan = checkoutTransaction.startChild("task", "process delivery"); - try { - throw new MainFragment.BackendAPIException("Failed to init delivery workflow"); - } catch (Exception e) { - Log.e("processDeliveryItem", e.getMessage()); - processDeliverySpan.setThrowable(e); - processDeliverySpan.setStatus(SpanStatus.INTERNAL_ERROR); - Sentry.captureException(e); - } - - if (processDeliverySpan.getStatus() != SpanStatus.INTERNAL_ERROR) { - processDeliverySpan.setStatus(SpanStatus.OK); - } + processDeliverySpan.setStatus(SpanStatus.OK); processDeliverySpan.finish(); Log.i("processDeliveryItem", "<<< processDeliveryItem"); }