When you are trying to debug something it is usually helpful to see the stacktrace of what called a function.
If you're inside of a try
expression, and within the catch
or rescue
block, that's easy - use the __STACKTRACE__
Special Form.
try do
# NOPE
rescue
ArgumentError ->
IO.puts("Stacktrace #{inspect(__STACKTRACE__)}")
catch
value ->
IO.puts("Stacktrace #{inspect(__STACKTRACE__)}")
else
# NOPE
after
# NOPE
end
For all other cases the incantation is a little more complicated (and if you don't think you can remember it, perhaps set up a snippet):
self()
|> Process.info(:current_stacktrace)
|> IO.inspect(label: "---------> stacktrace")