Skip to content

Commit 7b42e98

Browse files
committed
catch exception when no project is set
1 parent b8c5225 commit 7b42e98

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ui-integration/src/main/java/io/snabble/sdk/ui/integration/CheckoutFragment.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import android.view.ViewGroup;
88

99
import io.snabble.sdk.Checkout;
10-
import io.snabble.sdk.Project;
1110
import io.snabble.sdk.ui.SnabbleUI;
1211
import io.snabble.sdk.ui.telemetry.Telemetry;
1312

@@ -21,16 +20,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
2120
public void onDestroyView() {
2221
super.onDestroyView();
2322

24-
Project project = SnabbleUI.getProject();
25-
26-
if(project != null) {
27-
Checkout checkout = project.getCheckout();
23+
try {
24+
Checkout checkout = SnabbleUI.getProject().getCheckout();
2825
checkout.cancel();
2926

3027
if (checkout.getState() != Checkout.State.PAYMENT_APPROVED
3128
&& checkout.getState() != Checkout.State.NONE) {
3229
Telemetry.event(Telemetry.Event.CheckoutAbortByUser);
3330
}
31+
} catch (RuntimeException e) {
32+
// ignore exception that is thrown when no project is set
3433
}
3534
}
3635
}

0 commit comments

Comments
 (0)