diff options
author | Björn Gustavsson <[email protected]> | 2017-05-17 12:38:09 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-05-17 12:38:09 +0200 |
commit | 890bc8dddd62b5e14fd9bd38ea3317e47cc0b716 (patch) | |
tree | 32ec168d996d2ffb8a79671e75851f620dc13836 /lib/stdlib/src/escript.erl | |
parent | dfa81717e0e5b07eaecae536523c820368e900de (diff) | |
download | otp-890bc8dddd62b5e14fd9bd38ea3317e47cc0b716.tar.gz otp-890bc8dddd62b5e14fd9bd38ea3317e47cc0b716.tar.bz2 otp-890bc8dddd62b5e14fd9bd38ea3317e47cc0b716.zip |
escript: Pick up stacktrace a soon as possible
It happens to work today, but it is potentially unsafe to call
io:format/2 before calling erlang:get_stacktrace/0. Make the
code safe by calling erlang:get_stacktrace/0 directly after
catching the exception.
Diffstat (limited to 'lib/stdlib/src/escript.erl')
-rw-r--r-- | lib/stdlib/src/escript.erl | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl index 6e8f780f7c..f2629a47c2 100644 --- a/lib/stdlib/src/escript.erl +++ b/lib/stdlib/src/escript.erl @@ -284,8 +284,9 @@ start(EscriptOptions) -> io:format("escript: ~s\n", [Str]), my_halt(127); _:Reason -> + Stk = erlang:get_stacktrace(), io:format("escript: Internal error: ~p\n", [Reason]), - io:format("~p\n", [erlang:get_stacktrace()]), + io:format("~p\n", [Stk]), my_halt(127) end. |