From 99bbda28ee728aea14636010721e7a4acc55bb4a Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Sun, 4 Sep 2016 22:57:10 +0300 Subject: [PATCH] Store stack trace in exception --- lib/system/jssys.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 31d283cd77..39ce1183b3 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -109,6 +109,7 @@ proc rawWriteStackTrace(): string = result = "No stack traceback available\n" proc getStackTrace*(): string = rawWriteStackTrace() +proc getStackTrace*(e: ref Exception): string = e.trace proc unhandledException(e: ref Exception) {. compilerproc, asmNoStackFrame.} = @@ -142,6 +143,8 @@ proc raiseException(e: ref Exception, ename: cstring) {. when defined(nimphp): asm """throw new Exception($`e`["message"]);""" else: + when NimStackTrace: + e.trace = rawWriteStackTrace() asm "throw `e`;" proc reraiseException() {.compilerproc, asmNoStackFrame.} =