summary refs log tree commit diff stats
path: root/lib/system/jssys.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-05 05:56:15 -0700
committerGitHub <noreply@github.com>2020-05-05 14:56:15 +0200
commitc28a057a6bd5f20445e11d82c4028762ae1bf1b6 (patch)
treed5a6e7ab9e53dc68eda848c1c2dd3afc67972acb /lib/system/jssys.nim
parent6b7b5fb4fa7865d17f2433ddc49bac1483b19a01 (diff)
downloadNim-c28a057a6bd5f20445e11d82c4028762ae1bf1b6.tar.gz
fix js stacktraces, unify all file,line,col formatting into a single function (#14230)
* fix https://github.com/timotheecour/Nim/issues/135 ; unify all file,line,col formatting into a single function
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r--lib/system/jssys.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index 106283490..705a6a208 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -8,6 +8,7 @@
 #
 
 include system/indexerrors
+import std/private/miscdollars
 
 proc log*(s: cstring) {.importc: "console.log", varargs, nodecl.}
 
@@ -70,7 +71,7 @@ proc getCurrentExceptionMsg*(): string =
 
 proc auxWriteStackTrace(f: PCallFrame): string =
   type
-    TempFrame = tuple[procname: cstring, line: int]
+    TempFrame = tuple[procname: cstring, line: int, filename: cstring]
   var
     it = f
     i = 0
@@ -79,6 +80,7 @@ proc auxWriteStackTrace(f: PCallFrame): string =
   while it != nil and i <= high(tempFrames):
     tempFrames[i].procname = it.procname
     tempFrames[i].line = it.line
+    tempFrames[i].filename = it.filename
     inc(i)
     inc(total)
     it = it.prev
@@ -92,10 +94,9 @@ proc auxWriteStackTrace(f: PCallFrame): string =
     add(result, $(total-i))
     add(result, " calls omitted) ...\n")
   for j in countdown(i-1, 0):
+    result.toLocation($tempFrames[j].filename, tempFrames[j].line, 0)
+    add(result, " at ")
     add(result, tempFrames[j].procname)
-    if tempFrames[j].line > 0:
-      add(result, ", line: ")
-      add(result, $tempFrames[j].line)
     add(result, "\n")
 
 proc rawWriteStackTrace(): string =