aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-07-07 17:50:46 +0200
committerLoïc Hoguin <[email protected]>2011-07-07 17:50:46 +0200
commit87366e36adc74caffbb3680fe1cfd07fc5b2cfef (patch)
tree195a4beb90c0373e7b3aa119ec0f24d1bd684107
parent474f4e0bfab5a3dadc67e1b7f13c45b246e47433 (diff)
downloadcowboy-87366e36adc74caffbb3680fe1cfd07fc5b2cfef.tar.gz
cowboy-87366e36adc74caffbb3680fe1cfd07fc5b2cfef.tar.bz2
cowboy-87366e36adc74caffbb3680fe1cfd07fc5b2cfef.zip
Call websocket_close/4 *after* throwing the error
This ensures that an error thrown in handler_terminate/4 will be shown after the error from handler_call/6, in the expected order. As we already call WebSocketHandler:terminate/3, this should fix issue #23.
-rw-r--r--src/cowboy_http_websocket.erl4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl
index da1622c..fa3e50f 100644
--- a/src/cowboy_http_websocket.erl
+++ b/src/cowboy_http_websocket.erl
@@ -205,14 +205,14 @@ handler_call(State=#state{handler=Handler, opts=Opts}, Req, HandlerState,
{shutdown, Req2, HandlerState2} ->
websocket_close(State, Req2, HandlerState2, {normal, shutdown})
catch Class:Reason ->
- websocket_close(State, Req, HandlerState, {error, handler}),
error_logger:error_msg(
"** Handler ~p terminating in websocket_handle/3~n"
" for the reason ~p:~p~n** Message was ~p~n"
"** Options were ~p~n** Handler state was ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
[Handler, Class, Reason, Message, Opts,
- HandlerState, Req, erlang:get_stacktrace()])
+ HandlerState, Req, erlang:get_stacktrace()]),
+ websocket_close(State, Req, HandlerState, {error, handler})
end.
-spec websocket_send(binary(), #http_req{}) -> ok.