diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala index 4ea65cb5a7fc7ceb1226853d47687a0865c818d0..0e404dd5c460e643262b43acd70766d6a91c3a7d 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Config.scala @@ -133,11 +133,12 @@ class Config(var map: Map[String, Any]) extends Logging { */ protected[config] def apply(module: String, path: List[String], key: String, default: Any = null, freeVar: Boolean = true): ConfigValue = { val requestedIndex = ConfigValueIndex(module, path, key, freeVar) - if (contains(requestedIndex)) return foundCache(requestedIndex) + if (contains(requestedIndex)) foundCache(requestedIndex) else if (default != null) { defaultCache += (requestedIndex -> ConfigValue(requestedIndex, null, default, freeVar)) - return defaultCache(requestedIndex) - } else throw new IllegalStateException("Value in config could not be found but it seems required, index: " + requestedIndex) + defaultCache(requestedIndex) + } else ConfigValue(requestedIndex, null, null, freeVar) + //else throw new IllegalStateException("Value in config could not be found but it seems required, index: " + requestedIndex) } def writeReport(id: String, directory: String): Unit = { diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Configurable.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Configurable.scala index 54e6dfd170a8cb2e68f5c63dd8ca2675513cee7d..774b15d2dd97192a1c6fc8614938bb725571099c 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Configurable.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/Configurable.scala @@ -79,7 +79,6 @@ trait Configurable extends ImplicitConversions { * @param key Name of value * @param default Default value if not found * @param submodule Adds to the path - * @param required Default false, if true and value is not found this function will raise an exception * @param freeVar Default true, if set false value must exist in module * @param sample Default null, when set path is prefixed with "samples" -> "sampleID" * @param library Default null, when set path is prefixed with "libraries" -> "libraryID" @@ -88,7 +87,6 @@ trait Configurable extends ImplicitConversions { def apply(key: String, default: Any = null, submodule: String = null, - required: Boolean = false, freeVar: Boolean = true, sample: String = null, library: String = null): ConfigValue = { @@ -100,14 +98,8 @@ trait Configurable extends ImplicitConversions { val value = Config.getValueFromMap(defaults.toMap, ConfigValueIndex(m, p, key, freeVar)) if (value.isDefined) value.get.value else default } - if (!contains(key, submodule, freeVar, sample = s, library = l) && d == null) { - if (required) { - Logging.logger.error("Value in config could not be found but it is required, key: " + key + " module: " + m + " path: " + p) - throw new IllegalStateException("Value in config could not be found but it is required, key: " + key + " module: " + m + " path: " + p) - } else return null - } - if (d == null) return Config.global(m, p, key, freeVar = freeVar) - else return Config.global(m, p, key, d, freeVar) + if (d == null) Config.global(m, p, key, freeVar = freeVar) + else Config.global(m, p, key, d, freeVar) } /** diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala index cef97ffaa2472a8bc77b19f77b2454dde0fa68eb..c3a79b24ce3cefb1d6a35350fc9f9ce45659c671 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala @@ -332,7 +332,9 @@ object ConfigUtils extends Logging { private def requiredValue(value: ConfigValue): Unit = { if (!valueExists(value)) - throw new IllegalStateException("Value does not exist but is required, key: '" + value.requestIndex.key + "'") + throw new IllegalStateException("Value does not exist but is required, key: " + value.requestIndex.key + + " module: " + value.requestIndex.module + + (if (value.requestIndex.path != Nil) " path: " + value.requestIndex.path.mkString("->") else "")) } private def valueExists(value: ConfigValue): Boolean = {