better possible exception handling in processReq

This commit is contained in:
Ivan FB 2026-04-24 17:05:39 +02:00
parent f9f2025b98
commit 7c03bfd9ac
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270

View File

@ -151,7 +151,14 @@ proc processRequest[T](
nilProcess(request[].reqId)
else:
ctx[].registeredRequests[][reqId](request[].reqContent, ctx)
handleRes(await retFut, request)
let res =
try:
await retFut
except CatchableError as exc:
Result[string, string].err("Exception in processRequest for " & reqId & ": " & exc.msg)
handleRes(res, request)
proc ffiThreadBody[T](ctx: ptr FFIContext[T]) {.thread.} =
## FFI thread body that attends library user API requests