diff --git a/packages/stripe_platform_interface/lib/src/models/errors.dart b/packages/stripe_platform_interface/lib/src/models/errors.dart index 31be863a3..1278c5b62 100644 --- a/packages/stripe_platform_interface/lib/src/models/errors.dart +++ b/packages/stripe_platform_interface/lib/src/models/errors.dart @@ -51,6 +51,7 @@ class LocalizedErrorMessage with _$LocalizedErrorMessage { @JsonSerializable(explicitToJson: true) const factory LocalizedErrorMessage({ /// The error code for example Cancelled + @JsonKey(unknownEnumValue: FailureCode.Unknown) required FailureCode code, /// Localized error message if any @@ -73,7 +74,7 @@ class LocalizedErrorMessage with _$LocalizedErrorMessage { _$LocalizedErrorMessageFromJson(json); } -enum FailureCode { Failed, Canceled, Timeout } +enum FailureCode { Failed, Canceled, Timeout, Unknown } class StripeConfigException implements Exception { const StripeConfigException(this.message); diff --git a/packages/stripe_platform_interface/lib/src/models/errors.freezed.dart b/packages/stripe_platform_interface/lib/src/models/errors.freezed.dart index c2d661e97..8be8457dc 100644 --- a/packages/stripe_platform_interface/lib/src/models/errors.freezed.dart +++ b/packages/stripe_platform_interface/lib/src/models/errors.freezed.dart @@ -346,6 +346,7 @@ LocalizedErrorMessage _$LocalizedErrorMessageFromJson( /// @nodoc mixin _$LocalizedErrorMessage { /// The error code for example Cancelled + @JsonKey(unknownEnumValue: FailureCode.Unknown) FailureCode get code => throw _privateConstructorUsedError; /// Localized error message if any @@ -376,7 +377,7 @@ abstract class $LocalizedErrorMessageCopyWith<$Res> { _$LocalizedErrorMessageCopyWithImpl<$Res, LocalizedErrorMessage>; @useResult $Res call( - {FailureCode code, + {@JsonKey(unknownEnumValue: FailureCode.Unknown) FailureCode code, String? localizedMessage, String? message, String? stripeErrorCode, @@ -444,7 +445,7 @@ abstract class _$$LocalizedErrorMessageImplCopyWith<$Res> @override @useResult $Res call( - {FailureCode code, + {@JsonKey(unknownEnumValue: FailureCode.Unknown) FailureCode code, String? localizedMessage, String? message, String? stripeErrorCode, @@ -505,7 +506,7 @@ class __$$LocalizedErrorMessageImplCopyWithImpl<$Res> @JsonSerializable(explicitToJson: true) class _$LocalizedErrorMessageImpl implements _LocalizedErrorMessage { const _$LocalizedErrorMessageImpl( - {required this.code, + {@JsonKey(unknownEnumValue: FailureCode.Unknown) required this.code, this.localizedMessage, this.message, this.stripeErrorCode, @@ -517,6 +518,7 @@ class _$LocalizedErrorMessageImpl implements _LocalizedErrorMessage { /// The error code for example Cancelled @override + @JsonKey(unknownEnumValue: FailureCode.Unknown) final FailureCode code; /// Localized error message if any @@ -582,7 +584,8 @@ class _$LocalizedErrorMessageImpl implements _LocalizedErrorMessage { abstract class _LocalizedErrorMessage implements LocalizedErrorMessage { const factory _LocalizedErrorMessage( - {required final FailureCode code, + {@JsonKey(unknownEnumValue: FailureCode.Unknown) + required final FailureCode code, final String? localizedMessage, final String? message, final String? stripeErrorCode, @@ -595,6 +598,7 @@ abstract class _LocalizedErrorMessage implements LocalizedErrorMessage { @override /// The error code for example Cancelled + @JsonKey(unknownEnumValue: FailureCode.Unknown) FailureCode get code; @override diff --git a/packages/stripe_platform_interface/lib/src/models/errors.g.dart b/packages/stripe_platform_interface/lib/src/models/errors.g.dart index d8ca7f544..c9ad22a31 100644 --- a/packages/stripe_platform_interface/lib/src/models/errors.g.dart +++ b/packages/stripe_platform_interface/lib/src/models/errors.g.dart @@ -36,7 +36,8 @@ Map _$$StripeExceptionImplToJson( _$LocalizedErrorMessageImpl _$$LocalizedErrorMessageImplFromJson( Map json) => _$LocalizedErrorMessageImpl( - code: $enumDecode(_$FailureCodeEnumMap, json['code']), + code: $enumDecode(_$FailureCodeEnumMap, json['code'], + unknownValue: FailureCode.Unknown), localizedMessage: json['localizedMessage'] as String?, message: json['message'] as String?, stripeErrorCode: json['stripeErrorCode'] as String?, @@ -59,4 +60,5 @@ const _$FailureCodeEnumMap = { FailureCode.Failed: 'Failed', FailureCode.Canceled: 'Canceled', FailureCode.Timeout: 'Timeout', + FailureCode.Unknown: 'Unknown', };