@@ -184,13 +184,30 @@ template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
184184
185185 # TODO for some reason, copyrights are printed when doing `--help`
186186 {.push warning [ProveInit ]: off .}
187- let config = ConfType .load (
188- version = version, # but a short version string makes more sense...
189- copyrightBanner = clientId,
190- secondarySources = proc (config: ConfType , sources: auto ) =
191- if config.configFile.isSome:
192- sources.addConfigFile (Toml , config.configFile.get)
193- )
187+ let config = try :
188+ ConfType .load (
189+ version = version, # but a short version string makes more sense...
190+ copyrightBanner = clientId,
191+ secondarySources = proc (config: ConfType , sources: auto ) =
192+ if config.configFile.isSome:
193+ sources.addConfigFile (Toml , config.configFile.get)
194+ )
195+ except CatchableError as err:
196+ # We need to log to stderr here, because logging hasn't been configured yet
197+ stderr.write " Failure while loading the configuration:\n "
198+ stderr.write err.msg
199+ stderr.write " \n "
200+
201+ if err[] of ConfigurationError and
202+ err.parent != nil and
203+ err.parent[] of TomlFieldReadingError :
204+ let fieldName = ((ref TomlFieldReadingError )(err.parent)).field
205+ if fieldName in [" web3-url" , " bootstrap-node" ,
206+ " direct-peer" , " validator-monitor-pubkey" ]:
207+ stderr.write " Since the '" & fieldName & " ' option is allowed to " &
208+ " have more than one value, please make sure to supply " &
209+ " a properly formatted TOML array\n "
210+ quit 1
194211 {.pop .}
195212 config
196213
0 commit comments