Simplify error parser

This commit is contained in:
Zed
2020-06-01 21:53:21 +02:00
parent 2642e5efe4
commit 2fa76db099
4 changed files with 8 additions and 7 deletions

View File

@@ -30,6 +30,10 @@ template `with`*(ident; value: JsonNode; body): untyped =
template getCursor*(js: JsonNode): string =
js{"content", "operation", "cursor", "value"}.getStr
template getError*(js: JsonNode): Error =
if js.kind != JArray or js.len == 0: null
else: Error(js[0]{"code"}.getInt)
template parseTime(time: string; f: static string; flen: int): Time =
if time.len != flen: return
parseTime(time, f, localTimezone).utc.toTime