diff -r a8444f6a54f3 -r 43aa4625ab7e java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Thu Dec 26 22:39:38 2013 +0100 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Fri Dec 27 00:57:34 2013 +0100 @@ -68,8 +68,16 @@ this.databases = databases; } - public DatabaseDefinition getDatabase(String name) { - return findByName(databases, name); + /** + * @throws ConfigurationException if no database with this name is configured + */ + public DatabaseDefinition getDatabase(String name) throws ConfigurationException { + DatabaseDefinition dd = findByName(databases, name); + if (dd == null) { + throw new ConfigurationException("Database is not configured: " + name); + } else { + return dd; + } } @XmlElement(name = "formatter", namespace = CONFIGURATION) @@ -85,18 +93,20 @@ * @param name name of desired formatter. Looking for this name in user configuration, then in * buil-in formatters. If null, default from configuration or (if not configured) built-in * default is used. - * @return formatter definition or null if none for this name is found + * @return formatter definition + * @throws ConfigurationException if no formatter with this name was found */ - public FormatterDefinition getFormatter(String name) { + public FormatterDefinition getFormatter(String name) throws ConfigurationException { if (name == null) { - if (defaultFormatter == null) { - return getFormatter(DEFAULT_FORMATTER); - } else { - return getFormatter(defaultFormatter); - } + return defaultFormatter == null ? getFormatter(DEFAULT_FORMATTER) : getFormatter(defaultFormatter); } else { FormatterDefinition fd = findByName(formatters, name); - return fd == null ? findByName(buildInFormatters, name) : fd; + fd = fd == null ? findByName(buildInFormatters, name) : fd; + if (fd == null) { + throw new ConfigurationException("Formatter is not configured: " + name); + } else { + return fd; + } } }