com.clinia.exceptions.CliniaRetryException Maven / Gradle / Ivy
package com.clinia.exceptions;
import java.util.List;
/**
* Exception thrown when an error occurs during the retry strategy. For example: All hosts are
* unreachable.
*/
public class CliniaRetryException extends CliniaRuntimeException {
private static final long serialVersionUID = 1L;
private final List errors;
public CliniaRetryException(List errors) {
super("Error(s) while processing the retry strategy", errors.get(errors.size() - 1));
this.errors = errors;
}
public List getErrors() {
return errors;
}
@Override
public String getMessage() {
if (errors == null || errors.isEmpty()) {
return super.getMessage();
}
StringBuilder messageBuilder = new StringBuilder(super.getMessage());
for (Throwable error : errors) {
messageBuilder.append("\nCaused by: ").append(error);
}
return messageBuilder.toString();
}
@Override
public String toString() {
return getMessage();
}
}