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];