Skip to content

@UnisonPublic /gist:1480320
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
-module(stack_trace_test).
-export([
t1/0,
t2/0,
t_all/0
]).
t_all() ->
t1(),
t2().
t1() ->
try e1() of
Res -> Res
catch
throw:{application_error, Error} ->
io:format("t1 error ~p stacktrace ~p~n", [Error, erlang:get_stacktrace()])
end.
t2() ->
try e2() of
Res -> Res
catch
throw:{application_error, Error} ->
io:format("t2 error ~p stacktrace ~p~n", [Error, erlang:get_stacktrace()])
end.
e1() -> throw({application_error, very_bad}).
e2() -> raise_error(very_bad), ok.
raise_error(Error) -> throw({application_error, Error}).
@UnisonPublic

(erlweb@eva)15> stack_trace_test:t_all().
t1 error very_bad stacktrace [{stack_trace_test,e1,0},
{stack_trace_test,t1,0},
{stack_trace_test,t_all,0},
{erl_eval,do_apply,5},
{shell,exprs,7},
{shell,eval_exprs,7},
{shell,eval_loop,3}]
t2 error very_bad stacktrace [{stack_trace_test,raise_error,1},
{stack_trace_test,t2,0},
{erl_eval,do_apply,5},
{shell,exprs,7},
{shell,eval_exprs,7},
{shell,eval_loop,3}]
ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.