aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_websocket.erl
diff options
context:
space:
mode:
authorSteve Strong <[email protected]>2019-03-13 11:36:04 +0000
committerLoïc Hoguin <[email protected]>2019-04-03 13:54:32 +0200
commitbfee20e61e9f6f4ad2e2d39d68c9c94910c67bac (patch)
tree29b3cc7404dd55cbc05b9116da2c30c6046b8449 /src/cowboy_websocket.erl
parentcd9b04792caabdcb901ea17a3fee0c2414d5ab98 (diff)
downloadcowboy-bfee20e61e9f6f4ad2e2d39d68c9c94910c67bac.tar.gz
cowboy-bfee20e61e9f6f4ad2e2d39d68c9c94910c67bac.tar.bz2
cowboy-bfee20e61e9f6f4ad2e2d39d68c9c94910c67bac.zip
Bind erlang:get_stacktrace prior to making other calls
If we bind too late there might be an exception triggered in the terminate function and we will not get the correct stacktrace as a result.
Diffstat (limited to 'src/cowboy_websocket.erl')
-rw-r--r--src/cowboy_websocket.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cowboy_websocket.erl b/src/cowboy_websocket.erl
index a94a5ce..9fc2752 100644
--- a/src/cowboy_websocket.erl
+++ b/src/cowboy_websocket.erl
@@ -503,9 +503,10 @@ handler_call(State=#state{handler=Handler}, HandlerState,
{stop, HandlerState2} ->
websocket_close(State, HandlerState2, stop)
catch Class:Reason ->
+ StackTrace = erlang:get_stacktrace(),
websocket_send_close(State, {crash, Class, Reason}),
handler_terminate(State, HandlerState, {crash, Class, Reason}),
- erlang:raise(Class, Reason, erlang:get_stacktrace())
+ erlang:raise(Class, Reason, StackTrace)
end.
-spec handler_call_result(#state{}, any(), parse_state(), fun(), commands()) -> no_return().