From b5a14dc5ec9b778bca54de66a6cff32db98a43d4 Mon Sep 17 00:00:00 2001 From: Lincoln Baker <51833247+lbakerchef@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:40:04 -0600 Subject: [PATCH] CHEF-37251: Replace deprecated old-style catch expressions OTP 29 deprecates the old-style `catch Expr` construct. Rewrite each use as an equivalent try/catch that preserves the original behaviour. Signed-off-by: Lincoln Baker Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/lhttpc_manager.erl | 2 +- test/lhttpc_manager_tests.erl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lhttpc_manager.erl b/src/lhttpc_manager.erl index 17bbc90e..2b27793d 100644 --- a/src/lhttpc_manager.erl +++ b/src/lhttpc_manager.erl @@ -524,7 +524,7 @@ deliver_socket(Socket, {_, _, Ssl} = Dest, State) -> lhttpc_sock:setopts(Socket, [{active, once}], Ssl), deliver_socket(Socket, Dest, State#httpc_man{queues = Queues2}); _ -> % Something wrong with the socket; just remove it - catch lhttpc_sock:close(Socket, Ssl), + try lhttpc_sock:close(Socket, Ssl) catch _:_ -> ok end, State end end. diff --git a/test/lhttpc_manager_tests.erl b/test/lhttpc_manager_tests.erl index f863edee..d80bca7b 100644 --- a/test/lhttpc_manager_tests.erl +++ b/test/lhttpc_manager_tests.erl @@ -74,7 +74,7 @@ empty_manager() -> ?assertEqual(ok, stop_client(Client)), ?assertEqual(0, lhttpc_manager:connection_count(lhttpc_manager)), - catch gen_tcp:close(LS), + try gen_tcp:close(LS) catch _:_ -> ok end, unlink(whereis(lhttpc_manager)), ok. @@ -106,7 +106,7 @@ one_socket() -> ?assertEqual(ok, stop_client(Client1)), ?assertEqual(ok, stop_client(Client2)), - catch gen_tcp:close(LS), + try gen_tcp:close(LS) catch _:_ -> ok end, unlink(whereis(lhttpc_manager)), ok. @@ -144,7 +144,7 @@ connection_timeout() -> ?assertEqual(ok, ping_client(Client)), ?assertEqual(1, lhttpc_manager:connection_count(lhttpc_manager)), - catch gen_tcp:close(LS), + try gen_tcp:close(LS) catch _:_ -> ok end, ?assertEqual(ok, stop_client(Client)), unlink(whereis(lhttpc_manager)), ok. @@ -269,7 +269,7 @@ many_sockets() -> lhttpc_manager ! {tcp_closed, Socket3}, ?assertEqual(0, lhttpc_manager:connection_count(lhttpc_manager)), - catch gen_tcp:close(LS), + try gen_tcp:close(LS) catch _:_ -> ok end, ?assertEqual(ok, stop_client(Client1)), ?assertEqual(ok, stop_client(Client2)), ?assertEqual(ok, stop_client(Client3)), @@ -343,7 +343,7 @@ spawn_client() -> client_loop(Parent, Socket) -> receive stop -> - catch gen_tcp:close(Socket), + try gen_tcp:close(Socket) catch _:_ -> ok end, Parent ! stopped; {get_socket, Ref} -> Parent ! {socket, Ref, Socket},