Skip to content

Commit 17a4876

Browse files
committed
Make error processing a bit smarter and add comments as to why
1 parent 60487ec commit 17a4876

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/rabbit_control_main.erl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,16 @@ shutdown_node_and_wait_pid_to_stop(Node, Pid, Inform) ->
285285
"RabbitMQ node ~p running at PID ~s successfully shut down",
286286
[Node, Pid]),
287287
Res;
288-
{badrpc, {'EXIT', RpcErr}} ->
289-
{error, {error_during_shutdown, RpcErr}};
288+
% NB: this is the return value for any errors raised by
289+
% an RPC call to rabbit:stop_and_halt. We return error_during_shutdown
290+
% so that rabbit_cli:main can differentiate this error from
291+
% other badrpc errors
292+
{badrpc, {'EXIT', RpcErr0}} ->
293+
{error, {error_during_shutdown, RpcErr0}};
294+
% NB: rabbit_cli:main pretty-prints other badrpc errors using
295+
% rabbit_nodes:diagnostics, so don't modify the error here
296+
{badrpc, _}=RpcErr1 ->
297+
RpcErr1;
290298
Error ->
291299
{error, {error_during_shutdown, Error}}
292300
end.
@@ -295,8 +303,16 @@ action(shutdown, Node, [], _Opts, Inform) ->
295303
case rpc:call(Node, os, getpid, []) of
296304
Pid when is_list(Pid) ->
297305
shutdown_node_and_wait_pid_to_stop(Node, Pid, Inform);
298-
{badrpc, {'EXIT', RpcErr}} ->
299-
{error, {error_during_shutdown, RpcErr}};
306+
% NB: this is the rpc return value for any errors raised by
307+
% rpc:call. We return error_during_shutdown so that
308+
% rabbit_cli:main can differentiate this error from other badrpc
309+
% errors
310+
{badrpc, {'EXIT', RpcErr0}} ->
311+
{error, {error_during_shutdown, RpcErr0}};
312+
% NB: rabbit_cli:main pretty-prints other badrpc errors using
313+
% rabbit_nodes:diagnostics, so don't modify the error here
314+
{badrpc, _}=RpcErr1 ->
315+
RpcErr1;
300316
Error ->
301317
{error, {error_during_shutdown, Error}}
302318
end;

0 commit comments

Comments
 (0)