com.lafaspot.icap.client.exception.IcapException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icapclient Show documentation
Show all versions of icapclient Show documentation
Icap client to talk to Symantec server.
/**
*
*/
package com.lafaspot.icap.client.exception;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* IcapException - encapsulates failure reason.
*
* @author kraman
*
*/
public class IcapException extends Exception {
/** Failure type. */
private FailureType failureType;
/**
* The map of validation errors. Specifies what input caused the invalid input error. Can be null.
*/
@Nullable
private List errorDetail = null;
/**
* Constructor that takes in a string message.
*
* @param message the message
*/
public IcapException(@Nonnull final String message) {
super(message);
}
@Override
public String getMessage() {
final StringBuffer buf = new StringBuffer(super.getMessage());
if (null != errorDetail) {
buf.append(", Details:");
buf.append(errorDetail);
}
return buf.toString();
}
/**
* Constructor with failure type.
*
* @param failureType type of failure
*/
public IcapException(@Nonnull final FailureType failureType) {
super(failureType.getMessage());
this.failureType = failureType;
}
/**
* Constructor with failure type.
*
* @param failureType type of failure
* @param errorDetail more info on the error
*/
public IcapException(@Nonnull final FailureType failureType, @Nullable final List errorDetail) {
super(failureType.getMessage());
this.failureType = failureType;
this.errorDetail = errorDetail;
}
/**
* Constructor with failure type.
*
* @param failureType type of failure
* @param cause the wrapped exception
*/
public IcapException(@Nonnull final FailureType failureType, @Nullable final Throwable cause) {
super(failureType.getMessage(), cause);
}
/**
* Types of failures.
*
* @author kraman
*
*/
public static enum FailureType {
/** Message parsing failed. */
PARSE_ERROR("Parse error - failed to parse ICAP message"),
/** Not connected to Symantec AV Server. */
NOT_CONNECTED("Not connected to server"),
/** The session object is already in use. */
SESSION_IN_USE("Session in use.");
/** The error message. */
@Nonnull
private final String message;
/**
* private constructor to create the enum.
*
* @param message the string message
* */
@Nonnull
private FailureType(@Nonnull final String message) {
this.message = message;
}
/**
* Returns the string message.
*
* @return the cause
*/
@Nonnull
public String getMessage() {
return message;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy