Skip to content

Commit

Permalink
fix: parse unknown error
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesblasco committed Apr 21, 2024
1 parent 7f3f8a8 commit b5d6385
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -595,6 +598,7 @@ abstract class _LocalizedErrorMessage implements LocalizedErrorMessage {
@override

/// The error code for example Cancelled
@JsonKey(unknownEnumValue: FailureCode.Unknown)
FailureCode get code;
@override

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5d6385

Please sign in to comment.