diff options
author | Björn Gustavsson <[email protected]> | 2016-11-02 12:35:07 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-11-02 12:35:07 +0100 |
commit | 5fe36fac74630bcb25558efbd98e6a6ca5f02f5a (patch) | |
tree | 73ecf2a621fbcdd5f280164b11e86f74b68ee64d /lib/stdlib/src | |
parent | 1b205afda0a88e7740d6187990ab35562e9a48c4 (diff) | |
parent | 798f09de48b1a7abe43d54d6fa0377ad15c3f6aa (diff) | |
download | otp-5fe36fac74630bcb25558efbd98e6a6ca5f02f5a.tar.gz otp-5fe36fac74630bcb25558efbd98e6a6ca5f02f5a.tar.bz2 otp-5fe36fac74630bcb25558efbd98e6a6ca5f02f5a.zip |
Merge branch 'essen/stdlib/proc_lib-propagate-exceptions/PR-1088/OTP-14001'
* essen/stdlib/proc_lib-propagate-exceptions/PR-1088/OTP-14001:
Propagate exceptions fully when using proc_lib
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/proc_lib.erl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index 3dc1848550..363705b0f4 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -232,7 +232,7 @@ init_p(Parent, Ancestors, Fun) when is_function(Fun) -> Fun() catch Class:Reason -> - exit_p(Class, Reason) + exit_p(Class, Reason, erlang:get_stacktrace()) end. -spec init_p(pid(), [pid()], atom(), atom(), [term()]) -> term(). @@ -247,7 +247,7 @@ init_p_do_apply(M, F, A) -> apply(M, F, A) catch Class:Reason -> - exit_p(Class, Reason) + exit_p(Class, Reason, erlang:get_stacktrace()) end. -spec wake_up(atom(), atom(), [term()]) -> term(). @@ -257,22 +257,29 @@ wake_up(M, F, A) when is_atom(M), is_atom(F), is_list(A) -> apply(M, F, A) catch Class:Reason -> - exit_p(Class, Reason) + exit_p(Class, Reason, erlang:get_stacktrace()) end. -exit_p(Class, Reason) -> +exit_p(Class, Reason, Stacktrace) -> case get('$initial_call') of {M,F,A} when is_atom(M), is_atom(F), is_integer(A) -> MFA = {M,F,make_dummy_args(A, [])}, crash_report(Class, Reason, MFA), - exit(Reason); + erlang:raise(exit, exit_reason(Class, Reason, Stacktrace), Stacktrace); _ -> %% The process dictionary has been cleared or %% possibly modified. crash_report(Class, Reason, []), - exit(Reason) + erlang:raise(exit, exit_reason(Class, Reason, Stacktrace), Stacktrace) end. +exit_reason(error, Reason, Stacktrace) -> + {Reason, Stacktrace}; +exit_reason(exit, Reason, _Stacktrace) -> + Reason; +exit_reason(throw, Reason, Stacktrace) -> + {{nocatch, Reason}, Stacktrace}. + -spec start(Module, Function, Args) -> Ret when Module :: module(), Function :: atom(), |