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:
parent
6b7b5fb4fa
commit
c28a057a6b
7 changed files with 68 additions and 46 deletions
15
lib/std/private/miscdollars.nim
Normal file
15
lib/std/private/miscdollars.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
template toLocation*(result: var string, file: string | cstring, line: int, col: int) =
|
||||
## avoids spurious allocations
|
||||
# Hopefully this can be re-used everywhere so that if a user needs to customize,
|
||||
# it can be done in a single place.
|
||||
result.add file
|
||||
if line > 0:
|
||||
result.add "("
|
||||
# simplify this after moving moving `include strmantle` above import assertions`
|
||||
when declared(addInt): result.addInt line
|
||||
else: result.add $line
|
||||
if col > 0:
|
||||
result.add ", "
|
||||
when declared(addInt): result.addInt col
|
||||
else: result.add $col
|
||||
result.add ")"
|
||||
Loading…
Add table
Add a link
Reference in a new issue