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);
}
}