mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-08 00:43:06 +00:00
fix: wrap untracked protocol handler exceptions
This commit is contained in:
parent
10028a4df9
commit
d0850e9eef
@ -57,7 +57,15 @@ proc initProtocolHandler*(wl: WakuLightPush) =
|
||||
debug "push request", peerId=conn.peerId, requestId=req.requestId, pubsubTopic=pubsubTopic
|
||||
|
||||
var response: PushResponse
|
||||
let handleRes = await wl.pushHandler(conn.peerId, pubsubTopic, message)
|
||||
var handleRes: WakuLightPushResult[void]
|
||||
try:
|
||||
handleRes = await wl.pushHandler(conn.peerId, pubsubTopic, message)
|
||||
except Exception:
|
||||
response = PushResponse(is_success: false, info: some(getCurrentExceptionMsg()))
|
||||
waku_lightpush_errors.inc(labelValues = [messagePushFailure])
|
||||
error "pushed message handling failed", error= getCurrentExceptionMsg()
|
||||
|
||||
|
||||
if handleRes.isOk():
|
||||
response = PushResponse(is_success: true, info: some("OK"))
|
||||
else:
|
||||
|
||||
@ -72,7 +72,17 @@ proc initProtocolHandler(ws: WakuStore) =
|
||||
info "received history query", peerId=conn.peerId, requestId=requestId, query=request
|
||||
waku_store_queries.inc()
|
||||
|
||||
let responseRes = ws.queryHandler(request)
|
||||
var responseRes: HistoryResult
|
||||
try:
|
||||
responseRes = ws.queryHandler(request)
|
||||
except Exception:
|
||||
error "history query failed", peerId= $conn.peerId, requestId=requestId, error=getCurrentExceptionMsg()
|
||||
|
||||
let error = HistoryError(kind: HistoryErrorKind.UNKNOWN).toRPC()
|
||||
let response = HistoryResponseRPC(error: error)
|
||||
let rpc = HistoryRPC(requestId: requestId, response: some(response))
|
||||
await conn.writeLp(rpc.encode().buffer)
|
||||
return
|
||||
|
||||
if responseRes.isErr():
|
||||
error "history query failed", peerId= $conn.peerId, requestId=requestId, error=responseRes.error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user