summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-12-15 13:45:36 +0800
committerGitHub <noreply@github.com>2022-12-15 06:45:36 +0100
commit91ce8c385d4ccbaab8048cf0393b01cd72282272 (patch)
tree0f9e3b632394e701b48e8afb01fa5fd0d0318d61 /lib/std
parent9a50033d5b09ec3263a53bd2bb4182a8a50e6f4d (diff)
downloadNim-91ce8c385d4ccbaab8048cf0393b01cd72282272.tar.gz
fix #19580; add warning for bare except: clause (#21099)
* fix #19580; add warning for bare except: clause

* fixes some easy ones

* Update doc/manual.md

* fixes docs

* Update changelog.md

* addition

* Apply suggestions from code review

Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>

* Update doc/tut2.md

Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/assertions.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/std/assertions.nim b/lib/std/assertions.nim
index 03bab1b1b..5623ff8ef 100644
--- a/lib/std/assertions.nim
+++ b/lib/std/assertions.nim
@@ -98,6 +98,7 @@ template doAssertRaises*(exception: typedesc, code: untyped) =
   const begin = "expected raising '" & astToStr(exception) & "', instead"
   const msgEnd = " by: " & astToStr(code)
   template raisedForeign {.gensym.} = raiseAssert(begin & " raised foreign exception" & msgEnd)
+  {.warning[BareExcept]:off.}
   when Exception is exception:
     try:
       if true:
@@ -116,5 +117,6 @@ template doAssertRaises*(exception: typedesc, code: untyped) =
       mixin `$` # alternatively, we could define $cstring in this module
       raiseAssert(begin & " raised '" & $e.name & "'" & msgEnd)
     except: raisedForeign()
+  {.warning[BareExcept]:on.}
   if wrong:
     raiseAssert(begin & " nothing was raised" & msgEnd)