withReplacedSecretChallengeException<T> method
Replaces challenge-related exceptions by email-specific exceptions.
Implementation
Future<T> withReplacedSecretChallengeException<T>(
final Future<T> Function() fn,
) async {
try {
return await fn();
} on SecretChallengeException catch (e) {
throw switch (e) {
ChallengeRequestNotFoundException() =>
EmailPasswordResetRequestNotFoundException(),
ChallengeAlreadyUsedException() =>
EmailPasswordResetVerificationCodeAlreadyUsedException(),
ChallengeInvalidVerificationCodeException() =>
EmailPasswordResetInvalidVerificationCodeException(),
ChallengeExpiredException() =>
EmailPasswordResetRequestExpiredException(),
ChallengeNotVerifiedException() =>
EmailPasswordResetNotVerifiedException(),
ChallengeInvalidCompletionTokenException() =>
EmailPasswordResetInvalidVerificationCodeException(),
ChallengeRateLimitExceededException() =>
EmailPasswordResetTooManyVerificationAttemptsException(),
};
}
}