aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_stream_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-12-31 15:10:38 +0100
committerLoïc Hoguin <[email protected]>2019-12-31 15:10:38 +0100
commit3a7232b019f975a594a696eace46abcbfeec5b2e (patch)
treeadb3d7cb0d8bde26dc14a7d8c96af156ef3f37da /src/cowboy_stream_h.erl
parent3b85b808ae3cc48d19b71b72869ee59c25e70b00 (diff)
downloadcowboy-3a7232b019f975a594a696eace46abcbfeec5b2e.tar.gz
cowboy-3a7232b019f975a594a696eace46abcbfeec5b2e.tar.bz2
cowboy-3a7232b019f975a594a696eace46abcbfeec5b2e.zip
No longer use erlang:get_stacktrace/0
It has been deprecated in OTP and the new way is available on all supported OTP versions.
Diffstat (limited to 'src/cowboy_stream_h.erl')
-rw-r--r--src/cowboy_stream_h.erl31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/cowboy_stream_h.erl b/src/cowboy_stream_h.erl
index 71b2948..2a50d6a 100644
--- a/src/cowboy_stream_h.erl
+++ b/src/cowboy_stream_h.erl
@@ -15,10 +15,6 @@
-module(cowboy_stream_h).
-behavior(cowboy_stream).
--ifdef(OTP_RELEASE).
--compile({nowarn_deprecated_function, [{erlang, get_stacktrace, 0}]}).
--endif.
-
-export([init/3]).
-export([data/4]).
-export([info/3]).
@@ -285,33 +281,16 @@ send_request_body(Pid, Ref, fin, BodyLen, Data) ->
%% Request process.
-%% We catch all exceptions in order to add the stacktrace to
-%% the exit reason as it is not propagated by proc_lib otherwise
-%% and therefore not present in the 'EXIT' message. We want
-%% the stacktrace in order to simplify debugging of errors.
-%%
-%% This + the behavior in proc_lib means that we will get a
-%% {Reason, Stacktrace} tuple for every exceptions, instead of
-%% just for errors and throws.
-%%
-%% @todo Better spec.
+%% We add the stacktrace to exit exceptions here in order
+%% to simplify the debugging of errors. The proc_lib library
+%% already adds the stacktrace to other types of exceptions.
-spec request_process(cowboy_req:req(), cowboy_middleware:env(), [module()]) -> ok.
request_process(Req, Env, Middlewares) ->
- OTP = erlang:system_info(otp_release),
try
execute(Req, Env, Middlewares)
catch
- exit:Reason ->
- Stacktrace = erlang:get_stacktrace(),
- erlang:raise(exit, {Reason, Stacktrace}, Stacktrace);
- %% OTP 19 does not propagate any exception stacktraces,
- %% we therefore add it for every class of exception.
- _:Reason when OTP =:= "19" ->
- Stacktrace = erlang:get_stacktrace(),
- erlang:raise(exit, {Reason, Stacktrace}, Stacktrace);
- %% @todo I don't think this clause is necessary.
- Class:Reason ->
- erlang:raise(Class, Reason, erlang:get_stacktrace())
+ exit:Reason:Stacktrace ->
+ erlang:raise(exit, {Reason, Stacktrace}, Stacktrace)
end.
execute(_, _, []) ->