Handle missing keys in enr.Record.get()

This commit is contained in:
Zahary Karadjov 2019-12-13 19:29:42 +02:00 committed by zah
parent 992aeecd29
commit edd674662a
1 changed files with 2 additions and 0 deletions

View File

@ -101,6 +101,8 @@ proc get*[T: seq[byte] | string | SomeInteger](r: Record, key: string, typ: type
elif typ is string:
requireKind(f, kString)
return f.str
else:
raise newException(KeyError, "Key not found in ENR: " & key)
proc get*(r: Record, pubKey: var PublicKey): bool =
var pubkeyField: Field