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() =>
EmailAccountRequestNotFoundException(),
ChallengeAlreadyUsedException() =>
EmailAccountRequestVerificationCodeAlreadyUsedException(),
ChallengeInvalidVerificationCodeException() =>
EmailAccountRequestInvalidVerificationCodeException(),
ChallengeExpiredException() =>
EmailAccountRequestVerificationExpiredException(),
ChallengeNotVerifiedException() =>
EmailAccountRequestNotVerifiedException(),
ChallengeInvalidCompletionTokenException() =>
EmailAccountRequestInvalidVerificationCodeException(),
ChallengeRateLimitExceededException() =>
EmailAccountRequestVerificationTooManyAttemptsException(),
};
}
}