ch.jooel.config.ConfigurationException Maven / Gradle / Ivy
package ch.jooel.config;
import java.util.Collection;
public abstract class ConfigurationException extends RuntimeException {
protected static final String NEWLINE = String.format("%n");
private final Collection errors;
public ConfigurationException(String path, Collection errors) {
super(formatMessage(path, errors));
this.errors = errors;
}
public ConfigurationException(String path, Collection errors, Throwable cause) {
super(formatMessage(path, errors), cause);
this.errors = errors;
}
public Collection getErrors() {
return errors;
}
protected static String formatMessage(String file, Collection errors) {
final StringBuilder msg = new StringBuilder(file);
msg.append(errors.size() == 1 ? " has an error:" : " has the following errors:").append(NEWLINE);
for (String error : errors) {
msg.append(" * ").append(error).append(NEWLINE);
}
return msg.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy