use raises defect

This commit is contained in:
Dmitriy Ryajov 2021-05-25 11:05:50 -06:00
parent ce42674d80
commit b56ca11b74
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 15 additions and 16 deletions

View File

@ -107,7 +107,7 @@ method upgradeOutgoing*(
method upgradeIncoming*( method upgradeIncoming*(
self: MuxedUpgrade, self: MuxedUpgrade,
incomingConn: Connection): Future[void] {.async, gcsafe.} = # noraises incomingConn: Connection) {.async, gcsafe.} = # noraises
trace "Upgrading incoming connection", incomingConn trace "Upgrading incoming connection", incomingConn
let ms = newMultistream() let ms = newMultistream()
@ -208,24 +208,23 @@ proc init*(
connManager: connManager, connManager: connManager,
ms: ms) ms: ms)
proc streamHandler(conn: Connection) {.async, gcsafe.} = # noraises upgrader.streamHandler = proc(conn: Connection)
# trace "Starting stream handler", conn {.async, gcsafe, raises: [Defect].} =
try: trace "Starting stream handler", conn
await upgrader.ms.handle(conn) # handle incoming connection try:
except CancelledError as exc: await upgrader.ms.handle(conn) # handle incoming connection
raise exc except CancelledError as exc:
except CatchableError as exc: raise exc
# trace "exception in stream handler", conn, msg = exc.msg except CatchableError as exc:
discard trace "exception in stream handler", conn, msg = exc.msg
finally: finally:
await conn.closeWithEOF() await conn.closeWithEOF()
# trace "Stream handler done", conn trace "Stream handler done", conn
upgrader.streamHandler = streamHandler
for _, val in muxers: for _, val in muxers:
val.streamHandler = upgrader.streamHandler val.streamHandler = upgrader.streamHandler
val.muxerHandler = proc(muxer: Muxer): Future[void] = val.muxerHandler = proc(muxer: Muxer): Future[void]
{.raises: [Defect].} =
upgrader.muxerHandler(muxer) upgrader.muxerHandler(muxer)
return upgrader return upgrader