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).
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
Still haven't found a solution :( .
(looking for it today again, I've only found my old post)
This works:
template foo() =
{.line: instantiationInfo().}:
if true: raise newException(ValueError, "foo!")
proc foo1() =
foo()
foo()
foo()
foo1()