From db84cdc34cbdfc7d88ee2d8337ee62e84298ea2e Mon Sep 17 00:00:00 2001 From: Eric Oestrich Date: Fri, 15 Oct 2021 14:48:58 -0400 Subject: [PATCH] Use the new stacktrace syntax `erlang:get_stacktrace()` was deprecated in OTP 21 --- src/elli_ws_protocol.erl | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/elli_ws_protocol.erl b/src/elli_ws_protocol.erl index bdf4b47..ae8ed2a 100644 --- a/src/elli_ws_protocol.erl +++ b/src/elli_ws_protocol.erl @@ -92,14 +92,14 @@ upgrade(Req, Env, Handler, HandlerOpts) -> try websocket_upgrade(State, Req) of {ok, State2, Req2} -> handler_init(State2, Req2, HandlerOpts) catch - throw:Exc -> - handle_event(Req, Handler, websocket_throw, [Exc, erlang:get_stacktrace()], HandlerOpts), + throw:Exc:Stacktrace -> + handle_event(Req, Handler, websocket_throw, [Exc, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req); - error:Error -> - handle_event(Req, Handler, websocket_error, [Error, erlang:get_stacktrace()], HandlerOpts), + error:Error:Stacktrace -> + handle_event(Req, Handler, websocket_error, [Error, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req); - exit:Exit -> - handle_event(Req, Handler, websocket_exit, [Exit, erlang:get_stacktrace()], HandlerOpts), + exit:Exit:Stacktrace -> + handle_event(Req, Handler, websocket_exit, [Exit, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req) end. @@ -169,14 +169,14 @@ handler_init(State=#state{env=Env, handler=Handler}, Req, HandlerOpts) -> elli_ws_request_adapter:ensure_response(Req2, 400), {ok, Req2, [{result, closed}|Env]} catch - throw:Exc -> - handle_event(Req, Handler, websocket_throw, [Exc, erlang:get_stacktrace()], HandlerOpts), + throw:Exc:Stacktrace -> + handle_event(Req, Handler, websocket_throw, [Exc, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req); - error:Error -> - handle_event(Req, Handler, websocket_error, [Error, erlang:get_stacktrace()], HandlerOpts), + error:Error:Stacktrace -> + handle_event(Req, Handler, websocket_error, [Error, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req); - exit:Exit -> - handle_event(Req, Handler, websocket_exit, [Exit, erlang:get_stacktrace()], HandlerOpts), + exit:Exit:Stacktrace -> + handle_event(Req, Handler, websocket_exit, [Exit, Stacktrace], HandlerOpts), elli_ws_request_adapter:maybe_reply(400, Req) end. @@ -665,12 +665,12 @@ handler_call(State=#state{handler=Handler}, Req, HandlerState, {shutdown, Req2, HandlerState2} -> websocket_close(State, Req2, HandlerState2, {normal, shutdown}) catch - throw:Exc -> - handle_event(Req, Handler, websocket_throw, [Exc, erlang:get_stacktrace()], HandlerState); - error:Error -> - handle_event(Req, Handler, websocket_error, [Error, erlang:get_stacktrace()], HandlerState); - exit:Exit -> - handle_event(Req, Handler, websocket_exit, [Exit, erlang:get_stacktrace()], HandlerState) + throw:Exc:Stacktrace -> + handle_event(Req, Handler, websocket_throw, [Exc, Stacktrace], HandlerState); + error:Error:Stacktrace -> + handle_event(Req, Handler, websocket_error, [Error, Stacktrace], HandlerState); + exit:Exit:Stacktrace -> + handle_event(Req, Handler, websocket_exit, [Exit, Stacktrace], HandlerState) end. websocket_opcode(text) -> 1;