summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bakken <lbakken@pivotal.io>2017-10-25 08:57:01 -0700
committerLuke Bakken <lbakken@pivotal.io>2017-10-25 08:57:01 -0700
commit17a4876ac410abe6ba306ef568fa5838010fc7a8 (patch)
treea3e2945a937c1845e700d8c78d812ae16dafb124
parent60487ec7a2c6ab1f5c90504272bad277c49e7053 (diff)
downloadrabbitmq-server-git-17a4876ac410abe6ba306ef568fa5838010fc7a8.tar.gz
Make error processing a bit smarter and add comments as to why
-rw-r--r--src/rabbit_control_main.erl24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 934821891b..9bd4f2568e 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -285,8 +285,16 @@ shutdown_node_and_wait_pid_to_stop(Node, Pid, Inform) ->
"RabbitMQ node ~p running at PID ~s successfully shut down",
[Node, Pid]),
Res;
- {badrpc, {'EXIT', RpcErr}} ->
- {error, {error_during_shutdown, RpcErr}};
+ % NB: this is the return value for any errors raised by
+ % an RPC call to rabbit:stop_and_halt. We return error_during_shutdown
+ % so that rabbit_cli:main can differentiate this error from
+ % other badrpc errors
+ {badrpc, {'EXIT', RpcErr0}} ->
+ {error, {error_during_shutdown, RpcErr0}};
+ % NB: rabbit_cli:main pretty-prints other badrpc errors using
+ % rabbit_nodes:diagnostics, so don't modify the error here
+ {badrpc, _}=RpcErr1 ->
+ RpcErr1;
Error ->
{error, {error_during_shutdown, Error}}
end.
@@ -295,8 +303,16 @@ action(shutdown, Node, [], _Opts, Inform) ->
case rpc:call(Node, os, getpid, []) of
Pid when is_list(Pid) ->
shutdown_node_and_wait_pid_to_stop(Node, Pid, Inform);
- {badrpc, {'EXIT', RpcErr}} ->
- {error, {error_during_shutdown, RpcErr}};
+ % NB: this is the rpc return value for any errors raised by
+ % rpc:call. We return error_during_shutdown so that
+ % rabbit_cli:main can differentiate this error from other badrpc
+ % errors
+ {badrpc, {'EXIT', RpcErr0}} ->
+ {error, {error_during_shutdown, RpcErr0}};
+ % NB: rabbit_cli:main pretty-prints other badrpc errors using
+ % rabbit_nodes:diagnostics, so don't modify the error here
+ {badrpc, _}=RpcErr1 ->
+ RpcErr1;
Error ->
{error, {error_during_shutdown, Error}}
end;