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

io.dropwizard.configuration.ConfigurationException Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
package io.dropwizard.configuration;

import java.util.Collection;

/**
 * Base class for problems with a Configuration object.
 * 

* Refer to the implementations for different classes of problems: *

    *
  • Parsing errors: {@link ConfigurationParsingException}
  • *
  • Validation errors: {@link ConfigurationValidationException}
  • *
*/ public abstract class ConfigurationException extends Exception { protected static final String NEWLINE = String.format("%n"); private final Collection errors; /** * Creates a new ConfigurationException for the given path with the given errors. * * @param path the bad configuration path * @param errors the errors in the path */ public ConfigurationException(String path, Collection errors) { super(formatMessage(path, errors)); this.errors = errors; } /** * Creates a new ConfigurationException for the given path with the given errors and cause. * * @param path the bad configuration path * @param errors the errors in the path * @param cause the cause of the error(s) */ 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