Skip to content

Commit

Permalink
feat: brij error handling (#1651)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Bubochkin <ookami.kb@gmail.com>
  • Loading branch information
justinenerio and ookami-kb authored Jan 13, 2025
1 parent 53d4c1d commit fc059bd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class KycRepository extends ChangeNotifier {
return await _initWrapper(
() => _getUserData(includeValues: includeValues),
);
} on Exception {
} on Exception catch (exception) {
reportError(exception);

return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sealed class KycException with _$KycException implements Exception {
const factory KycException.invalidData() = KycInvalidData;
const factory KycException.invalidToken() = KycInvalidToken;
const factory KycException.genericError() = KycGenericError;
const factory KycException.phoneTooManyAttempts() = KycPhoneTooManyAttempts;
}

extension ErrorExt on Exception {
Expand All @@ -29,6 +30,8 @@ extension ErrorExt on Exception {
'invalid phone' => const KycException.invalidPhone(),
'invalid code' => const KycException.invalidCode(),
'invalid data' => const KycException.invalidData(),
'too many verification attempts' =>
const KycException.phoneTooManyAttempts(),
_ => const KycException.genericError(),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ extension KycBuildContext on BuildContext {

final message = switch (error) {
KycInvalidEmail() => context.l10n.invalidEmail,
_ => context.l10n.failedToSendVerificationCode,
KycInvalidCode() ||
KycInvalidData() ||
KycInvalidToken() ||
KycInvalidPhone() ||
KycPhoneTooManyAttempts() ||
KycGenericError() =>
context.l10n.failedToSendVerificationCode,
};

showCpErrorSnackbar(context, message: message);
Expand All @@ -50,7 +56,13 @@ extension KycBuildContext on BuildContext {

final message = switch (error) {
KycInvalidPhone() => context.l10n.invalidPhone,
_ => context.l10n.failedToSendVerificationCode,
KycPhoneTooManyAttempts() => context.l10n.phoneTooManyAttempts,
KycInvalidCode() ||
KycInvalidEmail() ||
KycInvalidData() ||
KycInvalidToken() ||
KycGenericError() =>
context.l10n.failedToSendVerificationCode,
};

showCpErrorSnackbar(context, message: message);
Expand Down
8 changes: 5 additions & 3 deletions packages/espressocash_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,9 @@
"pendingKycDialogTitle": "We’re still verifying your *identity.*",
"@pendingKycDialogTitle": {},
"pendingKycDialogMessage": "Your identity verification is currently under review and will be completed shortly. You can check the Activity page for real-time updates on your verification status.",
"@pendingKycDialogMessage": {},
"@pendingKycDialogMessage": {},
"continueVerification": "Continue Verification",
"@continueVerification": {}
}
"@continueVerification": {},
"phoneTooManyAttempts": "Too many verification attempts. Please try again later",
"@phoneTooManyAttempts": {}
}

0 comments on commit fc059bd

Please sign in to comment.