getErrorMessage method

String getErrorMessage(
  1. PlatformException e
)

Implementation

String getErrorMessage(PlatformException e) {
  switch (e.code) {
    case 'ERROR_INVALID_EMAIL': // -  If the [email] address is malformed.
      return 'msg_ERROR_INVALID_EMAIL'.tr;
    case 'ERROR_WRONG_PASSWORD': // -  If the [password] is wrong.
      return 'msg_ERROR_WRONG_PASSWORD'.tr;
    case 'ERROR_USER_NOT_FOUND': // -  If there is no user corresponding to the given [email] address, or if the user has been deleted.
      return 'msg_ERROR_USER_NOT_FOUND'.tr;
    case 'ERROR_USER_DISABLED': // -  If the user has been disabled (for example, in the Firebase console)
      return 'msg_ERROR_USER_DISABLED'.tr;
    case 'ERROR_TOO_MANY_REQUESTS': // -  If there was too many attempts to sign in as this user.
      return 'msg_ERROR_TOO_MANY_REQUESTS'.tr;
    case 'ERROR_OPERATION_NOT_ALLOWED': // -  Indicates that Email & Password accounts are not enabled.
      return 'msg_ERROR_OPERATION_NOT_ALLOWED'.tr;
    case 'ERROR_WEAK_PASSWORD': // - If the password is not strong enough.
      return 'msg_ERROR_WEAK_PASSWORD'.tr;
    case 'ERROR_EMAIL_ALREADY_IN_USE': // - If the email is already in use by a different account.
      return 'msg_ERROR_EMAIL_ALREADY_IN_USE'.tr;
    // Google Sign
    case 'failed_to_recover_auth': // - Error code indicating there was a failed attempt to recover user authentication.
      return 'msg_failed_to_recover_auth'.tr;
    case 'user_recoverable_auth': // - Error indicating that authentication can be recovered with user action
      return 'msg_user_recoverable_auth'.tr;
    case 'sign_in_required': // - Error code indicating there is no signed in user and interactive sign in
      return 'msg_sign_in_required'.tr;
    case 'sign_in_canceled': // - Error code indicating that interactive sign in process was canceled by the user
      return 'msg_sign_in_canceled'.tr;
    case 'network_error': // - Error code indicating network error. Retrying should resolve the problem.
      return 'msg_network_error'.tr;
    case 'sign_in_failed': // - Error code indicating that attempt to sign in failed.
      return 'msg_sign_in_failed'.tr;

    case 'ERROR_INVALID_CREDENTIAL': // - The [email] address is malformed
      return 'msg_ERROR_INVALID_CREDENTIAL'.tr;
    case 'ERROR_NOT_ALLOWED': // - That email and email sign-in link accounts are not enabled. Enable them in the Auth section of the Firebase console
      return 'msg_ERROR_NOT_ALLOWED'.tr;
    case 'ERROR_DISABLED': // - The user's account is disabled
      return 'msg_ERROR_DISABLED'.tr;
    case 'ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL': // - There already exists an account with the email address asserted by Google
      return 'msg_ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL'.tr;
    case 'ERROR_INVALID_ACTION_CODE': // - The action code in the link is malformed, expired, or has already been used.
      return 'msg_ERROR_INVALID_ACTION_CODE'.tr;
    case 'ERROR_INVALID_CUSTOM_TOKEN': // - The custom token format is incorrect.
      return 'msg_ERROR_INVALID_CUSTOM_TOKEN'.tr;
    case 'ERROR_CUSTOM_TOKEN_MISMATCH': // - Invalid configuration.
      return 'msg_ERROR_CUSTOM_TOKEN_MISMATCH'.tr;
    case 'EXPIRED_ACTION_CODE': // - The password reset code has expired.
      return 'msg_EXPIRED_ACTION_CODE'.tr;
    case 'INVALID_ACTION_CODE': // - The password reset code is invalid. This can happen if the code is malformed or has already been used.
      return 'msg_INVALID_ACTION_CODE'.tr;
    case 'USER_DISABLED': // - The user corresponding to the given password reset code has been disabled.
      return 'msg_USER_DISABLED'.tr;
    case 'USER_NOT_FOUND': // - There is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called.
      return 'msg_USER_NOT_FOUND'.tr;
    case 'WEAK_PASSWORD': // - The new password is not strong enough.
      return 'msg_WEAK_PASSWORD'.tr;
    default:
      return '${('msg_TraitementImpossible'.tr)}\nCase ${e.message}';
  }
}