aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_rest.erl
diff options
context:
space:
mode:
authorSergey Urbanovich <[email protected]>2013-06-07 21:06:27 +0400
committerSergey Urbanovich <[email protected]>2013-06-07 21:06:27 +0400
commit1577ec83645f4b4a76e8ac6b4d9cc59376ce38d4 (patch)
tree2179cc570f001042c10141cf55e6106e06d638bd /src/cowboy_rest.erl
parentbfbe1cc5c60471efe3e840f5658957ace0269dbd (diff)
downloadcowboy-1577ec83645f4b4a76e8ac6b4d9cc59376ce38d4.tar.gz
cowboy-1577ec83645f4b4a76e8ac6b4d9cc59376ce38d4.tar.bz2
cowboy-1577ec83645f4b4a76e8ac6b4d9cc59376ce38d4.zip
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. ```
Diffstat (limited to 'src/cowboy_rest.erl')
-rw-r--r--src/cowboy_rest.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index b87c7df..5f96b53 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -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