ensure `quit` on config error with `IOError` (#5011)
When there is an `IOError` while logging a configuration error, we don't actually `quit` the program. Catch `IOError` to always `quit`.
This commit is contained in:
parent
6cd63a89d8
commit
1086909e0b
|
@ -208,19 +208,22 @@ template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
|
||||||
)
|
)
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
# We need to log to stderr here, because logging hasn't been configured yet
|
# We need to log to stderr here, because logging hasn't been configured yet
|
||||||
stderr.write "Failure while loading the configuration:\n"
|
try:
|
||||||
stderr.write err.msg
|
stderr.write "Failure while loading the configuration:\n"
|
||||||
stderr.write "\n"
|
stderr.write err.msg
|
||||||
|
stderr.write "\n"
|
||||||
|
|
||||||
if err[] of ConfigurationError and
|
if err[] of ConfigurationError and
|
||||||
err.parent != nil and
|
err.parent != nil and
|
||||||
err.parent[] of TomlFieldReadingError:
|
err.parent[] of TomlFieldReadingError:
|
||||||
let fieldName = ((ref TomlFieldReadingError)(err.parent)).field
|
let fieldName = ((ref TomlFieldReadingError)(err.parent)).field
|
||||||
if fieldName in ["web3-url", "bootstrap-node",
|
if fieldName in ["web3-url", "bootstrap-node",
|
||||||
"direct-peer", "validator-monitor-pubkey"]:
|
"direct-peer", "validator-monitor-pubkey"]:
|
||||||
stderr.write "Since the '" & fieldName & "' option is allowed to " &
|
stderr.write "Since the '" & fieldName & "' option is allowed to " &
|
||||||
"have more than one value, please make sure to supply " &
|
"have more than one value, please make sure to supply " &
|
||||||
"a properly formatted TOML array\n"
|
"a properly formatted TOML array\n"
|
||||||
|
except IOError:
|
||||||
|
discard
|
||||||
quit 1
|
quit 1
|
||||||
{.pop.}
|
{.pop.}
|
||||||
config
|
config
|
||||||
|
|
Loading…
Reference in New Issue