diff --git a/confutils/envvar/writer.nim b/confutils/envvar/writer.nim index 36c5a7f..2b160e1 100644 --- a/confutils/envvar/writer.nim +++ b/confutils/envvar/writer.nim @@ -21,7 +21,7 @@ proc writeValue*(w: var EnvvarWriter, value: auto) = elif value is (SomePrimitives or range): let key = constructKey(w.prefix, w.key) setValue(key, value) - + elif value is Option: if value.isSome: w.writeValue value.get diff --git a/tests/test_config_file.nim b/tests/test_config_file.nim index 6f9ef26..ad586f3 100644 --- a/tests/test_config_file.nim +++ b/tests/test_config_file.nim @@ -149,13 +149,19 @@ proc readValue(r: var TomlReader, value = T r.parseAsString() proc readValue(r: var TomlReader, value: var ValidIpAddress) = - value = ValidIpAddress.init(r.parseAsString()) + try: + value = ValidIpAddress.init(r.parseAsString()) + except ValueError as ex: + raise newException(SerializationError, ex.msg) proc readValue(r: var TomlReader, value: var Port) = value = r.parseInt(int).Port proc readValue(r: var TomlReader, value: var GraffitiBytes) = - value = hexToByteArray[value.len](r.parseAsString()) + try: + value = hexToByteArray[value.len](r.parseAsString()) + except ValueError as ex: + raise newException(SerializationError, ex.msg) proc readValue(r: var EnvvarReader, value: var (InputFile | InputDir | OutFile | OutDir | ValidatorKeyPath)) =