Stricter error handling

This commit is contained in:
Zahary Karadjov 2020-06-16 01:04:49 +03:00 committed by zah
parent b3bd088ab7
commit 964a380191
1 changed files with 7 additions and 2 deletions

View File

@ -2,11 +2,16 @@ import
times, net,
json_serialization, nimcrypto/[hash, utils], eth_types
proc writeValue*(w: var JsonWriter, a: MDigest) {.inline.} =
{.push raises: [SerializationError, IOError, Defect].}
proc writeValue*(w: var JsonWriter, a: MDigest) =
w.writeValue a.data.toHex(true)
proc readValue*(r: var JsonReader, a: var MDigest) {.inline.} =
a = fromHex(type(a), r.readValue(string))
try:
a = fromHex(type(a), r.readValue(string))
except ValueError:
raiseUnexpectedValue(r, "Hex string expected")
proc writeValue*(w: var JsonWriter, value: StUint) {.inline.} =
w.writeValue $value