All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.geotab.http.exception.InvalidUserException Maven / Gradle / Ivy

/*
 *
 * 2020 Copyright (C) Geotab Inc. All rights reserved.
 */

package com.geotab.http.exception;

import com.geotab.model.enumeration.InvalidUserType;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;

/**
 * This exception is thrown on a logon with an incorrect user/password combination or when the
 * user's credentials become invalid.
 */
public class InvalidUserException extends JsonRpcErrorDataException {

  /**
   * Initializes a new instance.
   *
   * @param database        The database the user is trying to log in to.
   * @param exception       The inner exception.
   * @param invalidUserType The invalid user type.
   */
  public InvalidUserException(String database, Exception exception,
      InvalidUserType invalidUserType) {
    super(
        Optional.ofNullable(invalidUserType).orElse(InvalidUserType.DEFAULT).getDescription()
            + (StringUtils.isEmpty(database) ? "" : " @ '" + database + "'"),
        exception
    );
  }

  /**
   * Initializes a new instance.
   */
  public InvalidUserException() {
    this(null, null, null);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy