mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
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.
This commit is contained in:
parent
474f4e0bfa
commit
87366e36ad
1 changed files with 2 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue