Skip to content

Commit 3620b84

Browse files
committed
Improve stacktrace reporting
1 parent 6dee37b commit 3620b84

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

lib/elixir/src/elixir.erl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ eval_external_handler(Ann, FunOrModFun, Args) ->
401401
%% Add file+line information at the bottom
402402
Bottom =
403403
case erlang:get(?elixir_eval_env) of
404-
#{file := File} ->
405-
[{elixir_eval, '__FILE__', 1,
406-
[{file, elixir_utils:characters_to_list(File)}, {line, erl_anno:line(Ann)}]}];
407-
404+
#{'__struct__' := 'Elixir.Macro.Env'} = E ->
405+
'Elixir.Macro.Env':stacktrace(E#{line := erl_anno:line(Ann)});
408406
_ ->
409407
[]
410408
end,

lib/elixir/src/elixir_compiler.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ interpret(Quoted, ArgsList, #{line := Line} = E) ->
5454
ListBinding = lists:zipwith(fun({_, Var}, Arg) -> {Var, Arg} end, Vars, ArgsList),
5555
Binding = maps:from_list(ListBinding),
5656

57-
{value, Result, _} = elixir:erl_eval(ErlExprs, Binding, E),
57+
{value, Result, _} =
58+
try
59+
elixir:erl_eval(ErlExprs, Binding, E)
60+
catch
61+
Kind:Reason:Stacktrace ->
62+
erlang:raise(Kind, Reason, Stacktrace ++ 'Elixir.Macro.Env':stacktrace(E))
63+
end,
64+
5865
{Result, SE, EE}.
5966

6067
compile(Quoted, ArgsList, CompilerOpts, #{line := Line} = E) ->

0 commit comments

Comments
 (0)