diff options
author | Björn Gustavsson <[email protected]> | 2017-05-10 07:25:50 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-05-11 12:17:18 +0200 |
commit | 3681218fc3193693f4a22c818925a2765b5121fb (patch) | |
tree | 4e71e093ed01186bed40dcc36fe26cb31b343b60 /lib/stdlib/src/qlc.erl | |
parent | ba5d07704cc4b54139c48c7d034f389a31c37a89 (diff) | |
download | otp-3681218fc3193693f4a22c818925a2765b5121fb.tar.gz otp-3681218fc3193693f4a22c818925a2765b5121fb.tar.bz2 otp-3681218fc3193693f4a22c818925a2765b5121fb.zip |
qlc: Future-proof exception handling code
In the future, erlang:get_stacktrace/0 will probably only work
inside a the 'catch' block of a 'try' expression.
Future-proof the code by rewriting the old-style catch to
a try...catch.
Diffstat (limited to 'lib/stdlib/src/qlc.erl')
-rw-r--r-- | lib/stdlib/src/qlc.erl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/stdlib/src/qlc.erl b/lib/stdlib/src/qlc.erl index 20aaa2638c..535ca57a6b 100644 --- a/lib/stdlib/src/qlc.erl +++ b/lib/stdlib/src/qlc.erl @@ -1392,8 +1392,10 @@ next_loop(Pid, L, N) when N =/= 0 -> {caught, throw, Error, [?THROWN_ERROR | _]} -> Error; {caught, Class, Reason, Stacktrace} -> - _ = (catch erlang:error(foo)), - erlang:raise(Class, Reason, Stacktrace ++ erlang:get_stacktrace()); + CurrentStacktrace = try erlang:error(foo) + catch error:_ -> erlang:get_stacktrace() + end, + erlang:raise(Class, Reason, Stacktrace ++ CurrentStacktrace); error -> erlang:error({qlc_cursor_pid_no_longer_exists, Pid}) end; |