Commit 10495e73 authored by wyleung's avatar wyleung
Browse files

Raise an error if the JSON file for configs is not properly formatted in JSON

parent 0a0c64dd
......@@ -19,7 +19,7 @@ class Config(var map: Map[String,Any]) extends Logging {
logger.info("Loading config file: " + file)
loadConfigFile(file)
}
else logger.warn("QUEUE_CONFIG value found but file does not exist, no global config is loaded")
else logger.warn("QUEUE_CONFIG value found but file does not exist, no global config is loaded")
} else logger.warn("QUEUE_CONFIG value not found, no global config is loaded")
}
......@@ -28,6 +28,12 @@ class Config(var map: Map[String,Any]) extends Logging {
def loadConfigFile(configFile:File) {
var returnMap: Map[String,Any] = Map()
var configJson = JSON.parseFull(scala.io.Source.fromFile(configFile).mkString)
if ( configJson == None ) {
println( "[ERROR] The config JSON file is either not properly formatted or not a JSON file" )
System.exit(1)
}
this.logger.debug("Jsonfile: " + configFile)
this.logger.debug("Contain: " + configJson)
configJson.get match {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment