exception warning fixes (#403)
This commit is contained in:
parent
157ca4fea5
commit
a6ac5f2213
|
@ -395,7 +395,7 @@ proc futureContinue*(fut: FutureBase) {.raises: [Defect], gcsafe.} =
|
|||
# Every call to an `{.async.}` proc is redirected to call this function
|
||||
# instead with its original body captured in `fut.closure`.
|
||||
var next: FutureBase
|
||||
try:
|
||||
template iterate =
|
||||
while true:
|
||||
# Call closure to make progress on `fut` until it reaches `yield` (inside
|
||||
# `await` typically) or completes / fails / is cancelled
|
||||
|
@ -417,6 +417,19 @@ proc futureContinue*(fut: FutureBase) {.raises: [Defect], gcsafe.} =
|
|||
return
|
||||
|
||||
# Continue while the yielded future is already finished.
|
||||
|
||||
when chronosStrictException:
|
||||
try:
|
||||
iterate
|
||||
except CancelledError:
|
||||
fut.cancelAndSchedule()
|
||||
except CatchableError as exc:
|
||||
fut.fail(exc)
|
||||
finally:
|
||||
next = nil # GC hygiene
|
||||
else:
|
||||
try:
|
||||
iterate
|
||||
except CancelledError:
|
||||
fut.cancelAndSchedule()
|
||||
except CatchableError as exc:
|
||||
|
|
|
@ -1498,7 +1498,7 @@ proc wait*[T](fut: Future[T], timeout = -1): Future[T] {.
|
|||
|
||||
include asyncmacro2
|
||||
|
||||
proc runForever*() {.raises: [Defect, CatchableError].} =
|
||||
proc runForever*() =
|
||||
## Begins a never ending global dispatcher poll loop.
|
||||
## Raises different exceptions depending on the platform.
|
||||
while true:
|
||||
|
|
|
@ -408,7 +408,7 @@ proc init*(t: typedesc[IpNet], network: string): IpNet {.
|
|||
if len(parts) > 1:
|
||||
try:
|
||||
prefix = parseInt(parts[1])
|
||||
except:
|
||||
except ValueError:
|
||||
prefix = -1
|
||||
if prefix == -1:
|
||||
ipaddr = parseIpAddress(parts[1])
|
||||
|
@ -434,8 +434,8 @@ proc init*(t: typedesc[IpNet], network: string): IpNet {.
|
|||
result = t.init(host, mask)
|
||||
else:
|
||||
result = t.init(host, prefix)
|
||||
except:
|
||||
raise newException(TransportAddressError, "Incorrect network address!")
|
||||
except ValueError as exc:
|
||||
raise newException(TransportAddressError, exc.msg)
|
||||
|
||||
proc `==`*(n1, n2: IpNet): bool {.inline.} =
|
||||
## Returns ``true`` if networks ``n1`` and ``n2`` are equal in IP family and
|
||||
|
|
|
@ -463,7 +463,7 @@ suite "Datagram Transport test suite":
|
|||
try:
|
||||
await wait(dgram.join(), 1.seconds)
|
||||
result = true
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
|
||||
proc testBroadcast(): Future[int] {.async.} =
|
||||
|
|
|
@ -913,9 +913,9 @@ suite "HTTP client testing suite":
|
|||
await allFutures(f1, f2)
|
||||
check:
|
||||
f1.finished()
|
||||
f1.done()
|
||||
f1.completed()
|
||||
f2.finished()
|
||||
f2.done()
|
||||
f2.completed()
|
||||
f1.read() == (200, "ok", 0)
|
||||
f2.read() == (200, "ok", 0)
|
||||
session.connectionsCount == 2
|
||||
|
@ -976,9 +976,9 @@ suite "HTTP client testing suite":
|
|||
await allFutures(f1, f2)
|
||||
check:
|
||||
f1.finished()
|
||||
f1.done()
|
||||
f1.completed()
|
||||
f2.finished()
|
||||
f2.done()
|
||||
f2.completed()
|
||||
f1.read() == (200, "ok", 0)
|
||||
f2.read() == (200, "ok", 0)
|
||||
session.connectionsCount == 0
|
||||
|
|
|
@ -575,7 +575,7 @@ suite "Network utilities test suite":
|
|||
try:
|
||||
inet = IpNet.init(item[0])
|
||||
res = true
|
||||
except:
|
||||
except TransportAddressError:
|
||||
res = false
|
||||
check:
|
||||
$res == item[1]
|
||||
|
|
|
@ -689,7 +689,7 @@ suite "Stream Transport test suite":
|
|||
try:
|
||||
await wait(server.join(), 10.seconds)
|
||||
result = 1
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
|
||||
proc testWriteConnReset(address: TransportAddress): Future[int] {.async.} =
|
||||
|
@ -765,7 +765,7 @@ suite "Stream Transport test suite":
|
|||
try:
|
||||
transp = await connect(address)
|
||||
flag = true
|
||||
except:
|
||||
except CatchableError:
|
||||
server.stop()
|
||||
server.close()
|
||||
await server.join()
|
||||
|
|
Loading…
Reference in New Issue