Remap serialization errors to ConfigurationError

This commit is contained in:
Zahary Karadjov 2022-03-09 17:13:09 +02:00
parent 375b6276ca
commit 585059d2fb
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 8 additions and 2 deletions

View File

@ -820,8 +820,14 @@ macro configurationRtti(RecordType: type): untyped =
proc addConfigFile*(secondarySources: auto,
Format: type,
path: InputFile) =
secondarySources.data.add loadFile(Format, string path,
type(secondarySources.data[0]))
try:
secondarySources.data.add loadFile(Format, string path,
type(secondarySources.data[0]))
except SerializationError as err:
raise newException(ConfigurationError, err.formatMsg(string path), err)
except IOError as err:
raise newException(ConfigurationError,
"Failed to read config file at '" & string(path) & "': " & err.msg)
proc loadImpl[C, SecondarySources](
Configuration: typedesc[C],