Skip to content

Commit

Permalink
Workaround for nim-lang/Nim#12764 .
Browse files Browse the repository at this point in the history
Remove usage of getCurrentException().
  • Loading branch information
cheatfate committed Nov 28, 2019
1 parent 253aa7c commit dde8c01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions libp2p/daemon/daemonapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,8 @@ proc openStream*(api: DaemonAPI, peer: PeerID,
stream.flags.incl(Outbound)
stream.transp = transp
result = stream
except:
finally:
await api.closeConnection(transp)
raise getCurrentException()

proc streamHandler(server: StreamServer, transp: StreamTransport) {.async.} =
var api = getUserData[DaemonAPI](server)
Expand Down Expand Up @@ -933,14 +932,12 @@ proc addHandler*(api: DaemonAPI, protocols: seq[string],
protocols))
pb.withMessage() do:
api.servers.add(P2PServer(server: server, address: maddress))
except:
finally:
for item in protocols:
api.handlers.del(item)
server.stop()
server.close()
await server.join()
raise getCurrentException()
finally:
await api.closeConnection(transp)

proc listPeers*(api: DaemonAPI): Future[seq[PeerInfo]] {.async.} =
Expand Down Expand Up @@ -1301,9 +1298,8 @@ proc pubsubSubscribe*(api: DaemonAPI, topic: string,
ticket.transp = transp
asyncCheck pubsubLoop(api, ticket)
result = ticket
except:
finally:
await api.closeConnection(transp)
raise getCurrentException()

proc `$`*(pinfo: PeerInfo): string =
## Get string representation of ``PeerInfo`` object.
Expand Down
5 changes: 2 additions & 3 deletions libp2p/protocols/secure/secio.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Nim-LibP2P
## Copyright (c) 2019 Status Research & Development GmbH
## Licensed under either of
Expand Down Expand Up @@ -405,8 +404,8 @@ proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} =
try:
let msg = await sconn.readMessage()
await stream.pushTo(msg)
except:
trace "exception in secio", exc = getCurrentExceptionMsg()
except CatchableError as exc:
trace "exception in secio", exc = exc
return
finally:
trace "ending secio readLoop"
Expand Down

0 comments on commit dde8c01

Please sign in to comment.