newException supports setting of the 'parent' field
This commit is contained in:
parent
a1006b440d
commit
ca0b16fd33
1 changed files with 2 additions and 1 deletions
|
|
@ -2554,13 +2554,14 @@ else:
|
||||||
proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect,
|
proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect,
|
||||||
tags: [], raises: [].}
|
tags: [], raises: [].}
|
||||||
|
|
||||||
template newException*(exceptn: typedesc, message: string): expr =
|
template newException*(exceptn: typedesc, message: string; parentException: ref Exception = nil): expr =
|
||||||
## creates an exception object of type ``exceptn`` and sets its ``msg`` field
|
## creates an exception object of type ``exceptn`` and sets its ``msg`` field
|
||||||
## to `message`. Returns the new exception object.
|
## to `message`. Returns the new exception object.
|
||||||
var
|
var
|
||||||
e: ref exceptn
|
e: ref exceptn
|
||||||
new(e)
|
new(e)
|
||||||
e.msg = message
|
e.msg = message
|
||||||
|
e.parent = parentException
|
||||||
e
|
e
|
||||||
|
|
||||||
when hostOS == "standalone":
|
when hostOS == "standalone":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue