mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-29 18:53:58 +00:00
* 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>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user