Skip to content
Snippets Groups Projects
Commit 84c365c7 authored by wyleung's avatar wyleung
Browse files

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

parent 2cec3511
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment