mirror of https://github.com/status-im/nim-eth.git
don't swallow random exceptions (#11)
This commit is contained in:
parent
e1dbd76e1f
commit
e1af5a0c02
|
@ -384,7 +384,7 @@ proc decodeAuthMessageEip8(h: var Handshake, m: openarray[byte]): AuthStatus =
|
|||
h.remoteHPubkey = pubkey
|
||||
h.version = cast[ptr byte](versionBr.baseAddr)[]
|
||||
result = Success
|
||||
except:
|
||||
except CatchableError:
|
||||
result = RlpError
|
||||
|
||||
proc decodeAckMessageEip8*(h: var Handshake, m: openarray[byte]): AuthStatus =
|
||||
|
@ -417,7 +417,7 @@ proc decodeAckMessageEip8*(h: var Handshake, m: openarray[byte]): AuthStatus =
|
|||
copyMem(addr h.responderNonce[0], nonceBr.baseAddr, KeyLength)
|
||||
h.version = cast[ptr byte](versionBr.baseAddr)[]
|
||||
result = Success
|
||||
except:
|
||||
except CatchableError:
|
||||
result = RlpError
|
||||
|
||||
proc decodeAckMessageV4(h: var Handshake, m: openarray[byte]): AuthStatus =
|
||||
|
|
|
@ -164,7 +164,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} =
|
|||
if bestBlockNumber > syncCtx.endBlockNumber:
|
||||
trace "New sync end block number", number = bestBlockNumber
|
||||
syncCtx.endBlockNumber = bestBlockNumber
|
||||
except:
|
||||
except CatchableError:
|
||||
debug "Exception in getBestBlockNumber()",
|
||||
exc = getCurrentException().name,
|
||||
err = getCurrentExceptionMsg()
|
||||
|
@ -210,7 +210,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} =
|
|||
dataReceived = true
|
||||
else:
|
||||
warn "Bodies len != headers.len", bodies = bodies.len, headers = workItem.headers.len
|
||||
except:
|
||||
except CatchableError:
|
||||
# the success case sets `dataReceived`, so we can just fall back to the
|
||||
# failure path below. If we signal time-outs with exceptions such
|
||||
# failures will be easier to handle.
|
||||
|
@ -231,7 +231,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} =
|
|||
workItem.state = Initial
|
||||
try:
|
||||
await peer.disconnect(SubprotocolReason)
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
syncCtx.handleLostPeer()
|
||||
break
|
||||
|
@ -318,7 +318,7 @@ proc onPeerConnected(ctx: SyncContext, peer: Peer) =
|
|||
f.callback = proc(data: pointer) {.gcsafe.} =
|
||||
if f.failed:
|
||||
error "startSyncWithPeer failed", msg = f.readError.msg, peer
|
||||
except:
|
||||
except CatchableError:
|
||||
debug "Exception in startSyncWithPeer()",
|
||||
exc = getCurrentException().name,
|
||||
err = getCurrentExceptionMsg()
|
||||
|
|
|
@ -258,6 +258,7 @@ proc processClient(transp: DatagramTransport,
|
|||
proto.receive(a, buf)
|
||||
except:
|
||||
debug "Receive failed", err = getCurrentExceptionMsg()
|
||||
raise
|
||||
|
||||
proc open*(d: DiscoveryProtocol) =
|
||||
# TODO allow binding to specific IP / IPv6 / etc
|
||||
|
|
|
@ -198,6 +198,7 @@ proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} =
|
|||
debug "Exception in requestResolver()",
|
||||
exc = getCurrentException().name,
|
||||
err = getCurrentExceptionMsg()
|
||||
raise
|
||||
|
||||
proc registerMsg(protocol: ProtocolInfo,
|
||||
id: int, name: string,
|
||||
|
|
Loading…
Reference in New Issue