Improve rabbitmq-queues {add,delete}_member error messages

when target queue was not found.
This commit is contained in:
Michael Klishin 2023-05-02 13:28:29 +04:00
parent d5f16d4ce6
commit c9221bd717
No known key found for this signature in database
GPG Key ID: FF4F6501646A9C9A
4 changed files with 18 additions and 0 deletions

View File

@ -43,6 +43,8 @@ defmodule RabbitMQ.CLI.Core.ExitCodes do
def exit_code_for({:no_such_vhost, _}), do: exit_dataerr()
def exit_code_for({:no_such_user, _}), do: exit_nouser()
def exit_code_for(:not_found), do: exit_dataerr()
def exit_code_for({:not_found, _vhost, _name}), do: exit_dataerr()
def exit_code_for({:not_found, _object_type, _vhost, _name}), do: exit_dataerr()
def exit_code_for({:badrpc_multi, :timeout, _}), do: exit_tempfail()
def exit_code_for({:badrpc, :timeout}), do: exit_tempfail()
def exit_code_for({:badrpc, {:timeout, _}}), do: exit_tempfail()

View File

@ -49,6 +49,9 @@ defmodule RabbitMQ.CLI.Queues.Commands.AddMemberCommand do
{:error, :classic_queue_not_supported} ->
{:error, "Cannot add members to a classic queue"}
{:error, :not_found} ->
{:error, {:not_found, :queue, vhost, name}}
other ->
other
end

View File

@ -26,6 +26,9 @@ defmodule RabbitMQ.CLI.Queues.Commands.DeleteMemberCommand do
{:error, :classic_queue_not_supported} ->
{:error, "Cannot add members to a classic queue"}
{:error, :not_found} ->
{:error, {:not_found, :queue, vhost, name}}
other ->
other
end

View File

@ -468,6 +468,16 @@ defmodule RabbitMQCtl do
{:error, ExitCodes.exit_code_for(result), "Virtual host '#{vhost}' does not exist"}
end
defp format_error({:error, {:not_found, vhost, name} = result}, _opts, _) do
{:error, ExitCodes.exit_code_for(result),
"Object (queue, stream, exchange, etc) '#{name}' was not found in virtual host '#{vhost}}'"}
end
defp format_error({:error, {:not_found, object_type, vhost, name} = result}, _opts, _) do
{:error, ExitCodes.exit_code_for(result),
"#{object_type} '#{name}' was not found in virtual host '#{vhost}}'"}
end
defp format_error({:error, :not_found = result}, _opts, _) do
{:error, ExitCodes.exit_code_for(result),
"Object (queue, stream, exchange, etc) was not found"}