mirror of
https://github.com/status-im/nim-eth.git
synced 2025-01-11 14:54:33 +00:00
Add raises annotations to make exception tracking work (#336)
See https://github.com/status-im/nim-chronos/pull/166
This commit is contained in:
parent
16802c0e52
commit
0be863d2de
@ -139,13 +139,14 @@ type
|
|||||||
MessageHandlerDecorator* = proc(msgId: int, n: NimNode): NimNode
|
MessageHandlerDecorator* = proc(msgId: int, n: NimNode): NimNode
|
||||||
ThunkProc* = proc(x: Peer, msgId: int, data: Rlp): Future[void] {.gcsafe.}
|
ThunkProc* = proc(x: Peer, msgId: int, data: Rlp): Future[void] {.gcsafe.}
|
||||||
MessageContentPrinter* = proc(msg: pointer): string {.gcsafe.}
|
MessageContentPrinter* = proc(msg: pointer): string {.gcsafe.}
|
||||||
RequestResolver* = proc(msg: pointer, future: FutureBase) {.gcsafe.}
|
RequestResolver* = proc(msg: pointer, future: FutureBase)
|
||||||
|
{.gcsafe, raises:[Defect].}
|
||||||
NextMsgResolver* = proc(msgData: Rlp, future: FutureBase) {.gcsafe.}
|
NextMsgResolver* = proc(msgData: Rlp, future: FutureBase) {.gcsafe.}
|
||||||
PeerStateInitializer* = proc(peer: Peer): RootRef {.gcsafe.}
|
PeerStateInitializer* = proc(peer: Peer): RootRef {.gcsafe.}
|
||||||
NetworkStateInitializer* = proc(network: EthereumNode): RootRef {.gcsafe.}
|
NetworkStateInitializer* = proc(network: EthereumNode): RootRef {.gcsafe.}
|
||||||
HandshakeStep* = proc(peer: Peer): Future[void] {.gcsafe.}
|
HandshakeStep* = proc(peer: Peer): Future[void] {.gcsafe.}
|
||||||
DisconnectionHandler* = proc(peer: Peer,
|
DisconnectionHandler* = proc(peer: Peer, reason: DisconnectionReason):
|
||||||
reason: DisconnectionReason): Future[void] {.gcsafe.}
|
Future[void] {.gcsafe.}
|
||||||
|
|
||||||
ConnectionState* = enum
|
ConnectionState* = enum
|
||||||
None,
|
None,
|
||||||
|
@ -60,7 +60,8 @@ chronicles.formatIt(Peer): $(it.remote)
|
|||||||
|
|
||||||
include p2p_backends_helpers
|
include p2p_backends_helpers
|
||||||
|
|
||||||
proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} =
|
proc requestResolver[MsgType](msg: pointer, future: FutureBase)
|
||||||
|
{.gcsafe, raises:[Defect].} =
|
||||||
var f = Future[Option[MsgType]](future)
|
var f = Future[Option[MsgType]](future)
|
||||||
if not f.finished:
|
if not f.finished:
|
||||||
if msg != nil:
|
if msg != nil:
|
||||||
@ -72,10 +73,13 @@ proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} =
|
|||||||
# here. The only reasonable explanation is that the request should
|
# here. The only reasonable explanation is that the request should
|
||||||
# have timed out.
|
# have timed out.
|
||||||
if msg != nil:
|
if msg != nil:
|
||||||
|
try:
|
||||||
if f.read.isSome:
|
if f.read.isSome:
|
||||||
doAssert false, "trying to resolve a request twice"
|
doAssert false, "trying to resolve a request twice"
|
||||||
else:
|
else:
|
||||||
doAssert false, "trying to resolve a timed out request with a value"
|
doAssert false, "trying to resolve a timed out request with a value"
|
||||||
|
except CatchableError as e:
|
||||||
|
debug "Exception in requestResolver()", exc = e.name, err = e.msg
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if not f.read.isSome:
|
if not f.read.isSome:
|
||||||
@ -88,9 +92,8 @@ proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} =
|
|||||||
trace "TransportOsError during request", err = e.msg
|
trace "TransportOsError during request", err = e.msg
|
||||||
except TransportError:
|
except TransportError:
|
||||||
trace "Transport got closed during request"
|
trace "Transport got closed during request"
|
||||||
except Exception as e:
|
except CatchableError as e:
|
||||||
debug "Exception in requestResolver()", exc = e.name, err = e.msg
|
debug "Exception in requestResolver()", exc = e.name, err = e.msg
|
||||||
raise e
|
|
||||||
|
|
||||||
proc linkSendFailureToReqFuture[S, R](sendFut: Future[S], resFut: Future[R]) =
|
proc linkSendFailureToReqFuture[S, R](sendFut: Future[S], resFut: Future[R]) =
|
||||||
sendFut.addCallback() do (arg: pointer):
|
sendFut.addCallback() do (arg: pointer):
|
||||||
@ -360,7 +363,8 @@ proc registerRequest(peer: Peer,
|
|||||||
|
|
||||||
doAssert(not peer.dispatcher.isNil)
|
doAssert(not peer.dispatcher.isNil)
|
||||||
let requestResolver = peer.dispatcher.messages[responseMsgId].requestResolver
|
let requestResolver = peer.dispatcher.messages[responseMsgId].requestResolver
|
||||||
proc timeoutExpired(udata: pointer) = requestResolver(nil, responseFuture)
|
proc timeoutExpired(udata: pointer) {.gcsafe, raises:[Defect].} =
|
||||||
|
requestResolver(nil, responseFuture)
|
||||||
|
|
||||||
addTimer(timeoutAt, timeoutExpired, nil)
|
addTimer(timeoutAt, timeoutExpired, nil)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user