From 07ec0b7c5a6ecac415ccf023140f76e2856c7b4b Mon Sep 17 00:00:00 2001 From: Kevin Bloom Date: Tue, 10 Sep 2024 11:01:02 -0700 Subject: [PATCH] use tryParse in PurchasesErrorHelper to avoid FormatException --- lib/errors.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/errors.dart b/lib/errors.dart index e3f910403..fdcbc69cb 100644 --- a/lib/errors.dart +++ b/lib/errors.dart @@ -143,8 +143,8 @@ class PurchasesErrorHelper { /// } /// ``` static PurchasesErrorCode getErrorCode(PlatformException e) { - final errorCode = int.parse(e.code); - if (errorCode >= PurchasesErrorCode.values.length) { + final errorCode = int.tryParse(e.code); + if (errorCode == null || errorCode >= PurchasesErrorCode.values.length) { return PurchasesErrorCode.unknownError; } return PurchasesErrorCode.values[errorCode];