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
This commit is contained in:
Timothee Cour 2020-05-05 05:56:15 -07:00 • committed by GitHub
commit c28a057a6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 46 deletions

View file

@ -10,6 +10,8 @@
# Exception handling code. Carefully coded so that tiny programs which do not
# use the heap (and nor exceptions) do not include the GC or memory allocator.
import std/private/miscdollars
var
errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], benign,
nimcall.})
@ -240,11 +242,7 @@ proc auxWriteStackTrace(f: PFrame; s: var seq[StackTraceEntry]) =
template addFrameEntry(s: var string, f: StackTraceEntry|PFrame) =
var oldLen = s.len
add(s, f.filename)
if f.line > 0:
add(s, '(')
add(s, $f.line)
add(s, ')')
s.toLocation(f.filename, f.line, 0)
for k in 1..max(1, 25-(s.len-oldLen)): add(s, ' ')
add(s, f.procname)
when NimStackTraceMsgs: