1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Thu Dec 26 22:39:38 2013 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Fri Dec 27 00:57:34 2013 +0100
1.3 @@ -68,8 +68,16 @@
1.4 this.databases = databases;
1.5 }
1.6
1.7 - public DatabaseDefinition getDatabase(String name) {
1.8 - return findByName(databases, name);
1.9 + /**
1.10 + * @throws ConfigurationException if no database with this name is configured
1.11 + */
1.12 + public DatabaseDefinition getDatabase(String name) throws ConfigurationException {
1.13 + DatabaseDefinition dd = findByName(databases, name);
1.14 + if (dd == null) {
1.15 + throw new ConfigurationException("Database is not configured: " + name);
1.16 + } else {
1.17 + return dd;
1.18 + }
1.19 }
1.20
1.21 @XmlElement(name = "formatter", namespace = CONFIGURATION)
1.22 @@ -85,18 +93,20 @@
1.23 * @param name name of desired formatter. Looking for this name in user configuration, then in
1.24 * buil-in formatters. If null, default from configuration or (if not configured) built-in
1.25 * default is used.
1.26 - * @return formatter definition or null if none for this name is found
1.27 + * @return formatter definition
1.28 + * @throws ConfigurationException if no formatter with this name was found
1.29 */
1.30 - public FormatterDefinition getFormatter(String name) {
1.31 + public FormatterDefinition getFormatter(String name) throws ConfigurationException {
1.32 if (name == null) {
1.33 - if (defaultFormatter == null) {
1.34 - return getFormatter(DEFAULT_FORMATTER);
1.35 - } else {
1.36 - return getFormatter(defaultFormatter);
1.37 - }
1.38 + return defaultFormatter == null ? getFormatter(DEFAULT_FORMATTER) : getFormatter(defaultFormatter);
1.39 } else {
1.40 FormatterDefinition fd = findByName(formatters, name);
1.41 - return fd == null ? findByName(buildInFormatters, name) : fd;
1.42 + fd = fd == null ? findByName(buildInFormatters, name) : fd;
1.43 + if (fd == null) {
1.44 + throw new ConfigurationException("Formatter is not configured: " + name);
1.45 + } else {
1.46 + return fd;
1.47 + }
1.48 }
1.49 }
1.50