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