eh cleanups (#1458)

current exception sometimes buggy in nim
This commit is contained in:
Jacek Sieka 2020-08-06 20:47:39 +02:00 committed by GitHub
parent 8890d014be
commit f4c16ed0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -280,9 +280,9 @@ proc openStream(node: Eth2Node,
let protocolId = protocolId & (if peer.lacksSnappy: "ssz" else: "ssz_snappy")
try:
result = await dial(node.switch, peer.info.peerId, peer.info.addrs, protocolId)
except CancelledError:
raise
except CatchableError:
except CancelledError as exc:
raise exc
except CatchableError as exc:
# TODO: LibP2P should raise a more specific exception here
if peer.lacksSnappy == false:
peer.lacksSnappy = true
@ -290,7 +290,7 @@ proc openStream(node: Eth2Node,
peer, protocolId
return await openStream(node, peer, protocolId)
else:
raise
raise exc
proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer {.gcsafe.}

View File

@ -321,7 +321,7 @@ proc getBlockNumber(p: DataProviderRef, hash: BlockHash): Future[Eth1BlockNumber
except CatchableError as exc:
notice "Failed to get Eth1 block number from hash",
hash = $hash, err = exc.msg
raise
raise exc
template readJsonField(j: JsonNode,
fieldName: string,

View File

@ -94,12 +94,12 @@ proc waitForEvent[A, B](pool: PeerPool[A, B], eventType: EventType,
if not(fut1.finished):
fut1.cancel()
outgoingEvent(eventType).clear()
except CancelledError:
except CancelledError as exc:
if not(fut1.finished):
fut1.cancel()
if not(fut2.finished):
fut2.cancel()
raise
raise exc
elif PeerType.Incoming in filter:
await incomingEvent(eventType).wait()
incomingEvent(eventType).clear()
@ -497,13 +497,13 @@ proc acquire*[A, B](pool: PeerPool[A, B],
doAssert(PeerFlags.Acquired notin item[].flags)
item[].flags.incl(PeerFlags.Acquired)
peers.add(item[].data)
except CancelledError:
except CancelledError as exc:
# If we got cancelled, we need to return all the acquired peers back to
# pool.
for item in peers:
pool.release(item)
peers.setLen(0)
raise
raise exc
result = peers
proc acquireNoWait*[A, B](pool: PeerPool[A, B],