From 294fd72f4d8f3beb2e856f085e634549d978b7fd Mon Sep 17 00:00:00 2001 From: Alexander Sedov Date: Thu, 13 Oct 2016 12:46:18 +0300 Subject: Get stacktrace only once and as soon as possible. Fixes #1347. It turns out that pretty-printing uses throw-catch and thus garbages out the stack trace sometimes, so we should get it only once. --- src/rebar3.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar3.erl b/src/rebar3.erl index c665f20..47dc25a 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -286,10 +286,11 @@ handle_error({error, Error}) when is_list(Error) -> handle_error(Error) -> %% Nothing should percolate up from rebar_core; %% Dump this error to console - ?CRASHDUMP("Error: ~p~n~p~n~n", [Error, erlang:get_stacktrace()]), + StackTrace = erlang:get_stacktrace(), + ?CRASHDUMP("Error: ~p~n~p~n~n", [Error, StackTrace]), ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump", []), ?DEBUG("Uncaught error: ~p", [Error]), - case erlang:get_stacktrace() of + case StackTrace of [] -> ok; Trace -> ?DEBUG("Stack trace to the error location:~n~p", [Trace]) -- cgit v1.1