Skip to content

Commit

Permalink
Instead of throwing an error, return protocol_error
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonUnge committed May 14, 2024
1 parent 7b21b48 commit 608be08
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions deps/rabbit/src/rabbit_queue_type.erl
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,12 @@ is_compatible(Type, Durable, Exclusive, AutoDelete) ->
declare(Q0, Node) ->
Q = rabbit_queue_decorator:set(rabbit_policy:set(Q0)),
Mod = amqqueue:get_type(Q),
ok = check_vhost_queue_limit(Q),
Mod:declare(Q, Node).
case check_vhost_queue_limit(Q) of
ok ->
Mod:declare(Q, Node);
Error ->
Error
end.

-spec delete(amqqueue:amqqueue(), boolean(),
boolean(), rabbit_types:username()) ->
Expand Down Expand Up @@ -771,8 +775,11 @@ check_vhost_queue_limit(Q) ->
#resource{name = QueueName} = amqqueue:get_name(Q),
VHost = amqqueue:get_vhost(Q),
case rabbit_vhost_limit:is_over_queue_limit(VHost) of
false -> ok;
{true, Limit} -> rabbit_misc:precondition_failed("cannot declare queue '~ts': "
"queue limit in vhost '~ts' (~tp) is reached",
[QueueName, VHost, Limit])
false->
ok;
{true, Limit} ->
{protocol_error, precondition_failed,
"cannot declare queue '~ts': "
"queue limit in vhost '~ts' (~tp) is reached",
[QueueName, VHost, Limit]}
end.

0 comments on commit 608be08

Please sign in to comment.