mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-07 16:13:07 +00:00
http server better exception handling
This commit is contained in:
parent
9c2b36e636
commit
110c45a333
@ -80,13 +80,7 @@ proc serveHTTP*(rpcServer: RpcHttpHandler, request: HttpRequestRef):
|
|||||||
raise exc
|
raise exc
|
||||||
except CatchableError as exc:
|
except CatchableError as exc:
|
||||||
debug "Internal error while processing JSON-RPC call"
|
debug "Internal error while processing JSON-RPC call"
|
||||||
try:
|
return defaultResponse(exc)
|
||||||
return await request.respond(
|
|
||||||
Http503,
|
|
||||||
"Internal error while processing JSON-RPC call: " & exc.msg)
|
|
||||||
except HttpWriteError as exc:
|
|
||||||
error "Something error", msg=exc.msg
|
|
||||||
return defaultResponse()
|
|
||||||
|
|
||||||
proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback2 =
|
proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback2 =
|
||||||
return proc (req: RequestFence): Future[HttpResponseRef]
|
return proc (req: RequestFence): Future[HttpResponseRef]
|
||||||
@ -104,13 +98,7 @@ proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback2 =
|
|||||||
return res
|
return res
|
||||||
except CatchableError as exc:
|
except CatchableError as exc:
|
||||||
error "Internal error while processing JSON-RPC hook", msg=exc.msg
|
error "Internal error while processing JSON-RPC hook", msg=exc.msg
|
||||||
try:
|
return defaultResponse(exc)
|
||||||
return await request.respond(
|
|
||||||
Http503,
|
|
||||||
"Internal error while processing JSON-RPC hook: " & exc.msg)
|
|
||||||
except HttpWriteError as exc:
|
|
||||||
error "Something error", msg=exc.msg
|
|
||||||
return defaultResponse()
|
|
||||||
|
|
||||||
return await rpcServer.serveHTTP(request)
|
return await rpcServer.serveHTTP(request)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user