mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Don't overwrite stacktrace in cowboy_rest:error_terminate/2
This stacktrace is very useful in the `onresponse` hook. For example: ```erlang internal_error_hook(500, Headers, <<>>, Req) -> StackTrace = erlang:get_stacktrace(), Headers0 = [{N, V} || {N, V} <- Headers, N =/= <<"content-length">>], Body = io_lib:format("~p", [StackTrace]), {ok, Req0} = cowboy_req:reply(500, Headers0, Body, Req), Req0; internal_error_hook(Status, Headers, Body, Req) -> {ok, Req0} = cowboy_req:reply(Status, Headers, Body, Req), Req0. ```
This commit is contained in:
parent
bfbe1cc5c6
commit
1577ec8364
1 changed files with 1 additions and 1 deletions
|
@ -1086,7 +1086,7 @@ terminate(Req, State=#state{env=Env}) ->
|
|||
-spec error_terminate(cowboy_req:req(), #state{}) -> no_return().
|
||||
error_terminate(Req, State) ->
|
||||
rest_terminate(Req, State),
|
||||
erlang:throw({?MODULE, error}).
|
||||
erlang:raise(throw, {?MODULE, error}, erlang:get_stacktrace()).
|
||||
|
||||
rest_terminate(Req, #state{handler=Handler, handler_state=HandlerState}) ->
|
||||
case erlang:function_exported(Handler, rest_terminate, 2) of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue