From 6799f9e1cc38c7e3e1b1a25de6b522a592e772c8 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 14 Dec 2023 10:45:00 +0100 Subject: [PATCH] Fix BareExcept warnings --- asynctest/templates.nim | 4 ++++ testmodules/stdlib/testfail.nim | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/asynctest/templates.nim b/asynctest/templates.nim index bb7082b..b8c64d1 100644 --- a/asynctest/templates.nim +++ b/asynctest/templates.nim @@ -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) = diff --git a/testmodules/stdlib/testfail.nim b/testmodules/stdlib/testfail.nim index ed4b390..0614f50 100644 --- a/testmodules/stdlib/testfail.nim +++ b/testmodules/stdlib/testfail.nim @@ -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":