generateExceptionMessage method

dynamic generateExceptionMessage (
  1. dynamic exceptionCode
)

Given a particular AuthResultStatus, return a particular exception message.

Implementation

static generateExceptionMessage(exceptionCode) {
  String errorMessage;
  switch (exceptionCode) {
    case AuthResultStatus.invalidEmail:
      errorMessage = "Your email address appears to be malformed.";
      break;
    case AuthResultStatus.wrongPassword:
      errorMessage = "Your email address or password is incorrect.";
      break;
    case AuthResultStatus.userNotFound:
      errorMessage = "This is not a registered email address. Please Create an account.";
      break;
    case AuthResultStatus.userDisabled:
      errorMessage = "User with this email has been disabled.";
      break;
    case AuthResultStatus.tooManyRequests:
      errorMessage = "Too many requests. Try again later.";
      break;
    case AuthResultStatus.operationNotAllowed:
      errorMessage = "Signing in with Email and Password is not enabled.";
      break;
    case AuthResultStatus.emailAlreadyExists:
      errorMessage =
      "The email has already been registered. Please login or reset your password.";
      break;
    default:
      errorMessage = "An undefined Error happened.";
  }

  return errorMessage;
}