chore(nim): Adds try/catch block to fromEvent

This commit is contained in:
Boris Melnik 2023-05-31 22:19:45 +03:00
parent 73eb12c914
commit 54709cb1c5
1 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import json
import json, chronicles
import base
import signal_type
@ -10,8 +10,12 @@ type StatusUpdatesTimedoutSignal* = ref object of Signal
statusUpdates*: seq[StatusUpdateDto]
proc fromEvent*(T: type StatusUpdatesTimedoutSignal, jsonSignal: JsonNode): StatusUpdatesTimedoutSignal =
result = StatusUpdatesTimedoutSignal()
result.signalType = SignalType.StatusUpdatesTimedout
for jsonStatusUpdate in jsonSignal["event"]:
var statusUpdate = jsonStatusUpdate.toStatusUpdateDto()
result.statusUpdates.add(statusUpdate)
try:
result = StatusUpdatesTimedoutSignal()
result.signalType = SignalType.StatusUpdatesTimedout
for jsonStatusUpdate in jsonSignal["event"]:
var statusUpdate = jsonStatusUpdate.toStatusUpdateDto()
result.statusUpdates.add(statusUpdate)
except Exception as e:
let errDescription = e.msg
error "error from event: ", errDescription