Skip to content

Commit 585059d

Browse files
committed
Remap serialization errors to ConfigurationError
1 parent 375b627 commit 585059d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

confutils.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,14 @@ macro configurationRtti(RecordType: type): untyped =
820820
proc addConfigFile*(secondarySources: auto,
821821
Format: type,
822822
path: InputFile) =
823-
secondarySources.data.add loadFile(Format, string path,
824-
type(secondarySources.data[0]))
823+
try:
824+
secondarySources.data.add loadFile(Format, string path,
825+
type(secondarySources.data[0]))
826+
except SerializationError as err:
827+
raise newException(ConfigurationError, err.formatMsg(string path), err)
828+
except IOError as err:
829+
raise newException(ConfigurationError,
830+
"Failed to read config file at '" & string(path) & "': " & err.msg)
825831

826832
proc loadImpl[C, SecondarySources](
827833
Configuration: typedesc[C],

0 commit comments

Comments
 (0)