From ca0b16fd337d15abd2ea873a06dbca85777d886e Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 26 Jan 2017 15:20:24 +0100 Subject: [PATCH] newException supports setting of the 'parent' field --- lib/system.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index 1e6d2dff4a..86edccfe99 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2554,13 +2554,14 @@ else: proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect, 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 ## to `message`. Returns the new exception object. var e: ref exceptn new(e) e.msg = message + e.parent = parentException e when hostOS == "standalone":