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:
Etan Kissling 2023-05-31 22:21:49 +02:00 committed by GitHub
parent 6cd63a89d8
commit 1086909e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 12 deletions

View File

@ -208,6 +208,7 @@ template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
)
except CatchableError as err:
# We need to log to stderr here, because logging hasn't been configured yet
try:
stderr.write "Failure while loading the configuration:\n"
stderr.write err.msg
stderr.write "\n"
@ -221,6 +222,8 @@ template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
stderr.write "Since the '" & fieldName & "' option is allowed to " &
"have more than one value, please make sure to supply " &
"a properly formatted TOML array\n"
except IOError:
discard
quit 1
{.pop.}
config