Let's say I have a frequently used template foo, used all over my code. If there is an exception thrown inside code inserted by foo there is no way to see line numbers (on the stacktrace) of the proc which instantiated it. Is there a way to disable line number inside templates?
2016-01-19 12:45:21

Hi @zielmicha, is this what you're looking for? instantiationInfo

There's also getStackTrace, that may be useful to you (but apparently only in debug builds).

2016-01-19 13:00:18

instantiationInfo is helpful, but I'd like to achieve something different.

template foo(): stmt =
  if true: raise newException(ValueError, "foo!")

proc foo1() =
  foo()
  foo()
  foo()

foo1()

This code shows:

Traceback (most recent call last)
foomodule.nim(9)         foomodule
foomodule.nim(2)         foo1

so I don't know which foo caused the exception. I would like to be able to temporarily disable line number tracking in templates, so the stack trace would be:

Traceback (most recent call last)
foomodule.nim(9)         foomodule
foomodule.nim(5)         foo1

2016-01-19 16:54:53
I'm just trying to figure out exactly the same. Did you find a solution to that? 2017-07-15 16:16:26