GRAILS-2.5 Handling syntax errors on external configuration

52 views Asked by At

I have application developed using Grails 2.5.

In the the "Config.groovy" file i have included external configuration file like this:

grails.config.locations = []
def locationAdder = ConfigFinder.&addLocation.curry(grails.config.locations)

[CONFIG-1           : "base_config.groovy",
 CONFIG-2           : "app_configuration.groovy"
].each { envName, defaultFileName -> locationAdder(envName, defaultFileName) }

In the "app_configuration.groovy" file i have all the application level configuration.

My question is how to catch the "syntax errors" when server is loading this configuration files, like ex.:

if i have configuration like

some_configuration=["key": "value"]

and if it has an syntax errors like

some_configuration=["key": "value

Notice that above it missed double quote and ending bracket, in this case the server will not load all the configurations.

If any one know that how to catch exception and reload the configurations with corrected configuration.

1

There are 1 answers

0
Kambiz On

You can not catch Exception in external config. You may just add some log which in case of failure, at least have got some clue where it is failed.

println "External config: Part 1 loaded " 
println "External Config: Part n loaded " 
....