Fix BareExcept warnings

This commit is contained in:
Mark Spanbroek 2023-12-14 10:45:00 +01:00 committed by Giuliano Mega
parent 3f89e84f7c
commit 6799f9e1cc
2 changed files with 5 additions and 1 deletions

View File

@ -4,14 +4,18 @@ template launderExceptions(body: typed) =
## exist in asyncdispatch. We therefore launder all real instances of
## Exception into CatchableError and make Chronos happy while not losing
## context information for the remainder of the exception types.
{.push warning[BareExcept]:off.}
try:
{.push warning[BareExcept]:on.}
body
{.pop.}
except Defect as ex:
raise ex
except CatchableError as ex:
raise ex
except Exception as ex:
raise newException(Defect, ex.msg, ex)
{.pop.}
template suite*(name, body) =

View File

@ -26,7 +26,7 @@ suite "reports unhandled exception when teardown handles exceptions too":
teardown:
try:
await someAsyncProc()
except:
except CatchableError:
discard
test "should fail, but not crash":