@@ -930,15 +930,6 @@ handle_exception(Reason, State = #ch{cfg = #conf{protocol = Protocol,
930930 {stop , normal , State1 }
931931 end .
932932
933- -spec precondition_failed (string ()) -> no_return ().
934-
935- precondition_failed (Format ) -> precondition_failed (Format , []).
936-
937- -spec precondition_failed (string (), [any ()]) -> no_return ().
938-
939- precondition_failed (Format , Params ) ->
940- rabbit_misc :protocol_error (precondition_failed , Format , Params ).
941-
942933return_queue_declare_ok (# resource {name = ActualName },
943934 NoWait , MessageCount , ConsumerCount ,
944935 # ch {cfg = Cfg } = State ) ->
@@ -995,15 +986,15 @@ check_user_id_header(#'P_basic'{user_id = Claimed},
995986 tags = Tags }}}) ->
996987 case lists :member (impersonator , Tags ) of
997988 true -> ok ;
998- false -> precondition_failed (
989+ false -> rabbit_misc : precondition_failed (
999990 " user_id property set to '~ts ' but authenticated user was "
1000991 " '~ts '" , [Claimed , Actual ])
1001992 end .
1002993
1003994check_expiration_header (Props ) ->
1004995 case rabbit_basic :parse_expiration (Props ) of
1005996 {ok , _ } -> ok ;
1006- {error , E } -> precondition_failed (" invalid expiration '~ts ': ~tp " ,
997+ {error , E } -> rabbit_misc : precondition_failed (" invalid expiration '~ts ': ~tp " ,
1007998 [Props # 'P_basic' .expiration , E ])
1008999 end .
10091000
@@ -1074,15 +1065,15 @@ check_msg_size(Content, MaxMessageSize, GCThreshold) ->
10741065 _ ->
10751066 " message size ~B is larger than configured max size ~B "
10761067 end ,
1077- precondition_failed (ErrorMessage ,
1068+ rabbit_misc : precondition_failed (ErrorMessage ,
10781069 [Size , MaxMessageSize ]);
10791070 _ -> ok
10801071 end .
10811072
10821073check_vhost_queue_limit (# resource {name = QueueName }, VHost ) ->
10831074 case rabbit_vhost_limit :is_over_queue_limit (VHost ) of
10841075 false -> ok ;
1085- {true , Limit } -> precondition_failed (" cannot declare queue '~ts ': "
1076+ {true , Limit } -> rabbit_misc : precondition_failed (" cannot declare queue '~ts ': "
10861077 " queue limit in vhost '~ts ' (~tp ) is reached" ,
10871078 [QueueName , VHost , Limit ])
10881079
@@ -1704,7 +1695,7 @@ handle_method(#'queue.purge'{nowait = NoWait} = Method,
17041695 end ;
17051696
17061697handle_method (# 'tx.select' {}, _ , # ch {confirm_enabled = true }) ->
1707- precondition_failed (" cannot switch from confirm to tx mode" );
1698+ rabbit_misc : precondition_failed (" cannot switch from confirm to tx mode" );
17081699
17091700handle_method (# 'tx.select' {}, _ , State = # ch {tx = none }) ->
17101701 {reply , # 'tx.select_ok' {}, State # ch {tx = new_tx ()}};
@@ -1713,7 +1704,7 @@ handle_method(#'tx.select'{}, _, State) ->
17131704 {reply , # 'tx.select_ok' {}, State };
17141705
17151706handle_method (# 'tx.commit' {}, _ , # ch {tx = none }) ->
1716- precondition_failed (" channel is not transactional" );
1707+ rabbit_misc : precondition_failed (" channel is not transactional" );
17171708
17181709handle_method (# 'tx.commit' {}, _ , State = # ch {tx = {Deliveries , Acks },
17191710 limiter = Limiter }) ->
@@ -1731,7 +1722,7 @@ handle_method(#'tx.commit'{}, _, State = #ch{tx = {Deliveries, Acks},
17311722 {noreply , maybe_complete_tx (State3 # ch {tx = committing })};
17321723
17331724handle_method (# 'tx.rollback' {}, _ , # ch {tx = none }) ->
1734- precondition_failed (" channel is not transactional" );
1725+ rabbit_misc : precondition_failed (" channel is not transactional" );
17351726
17361727handle_method (# 'tx.rollback' {}, _ , State = # ch {unacked_message_q = UAMQ ,
17371728 tx = {_Msgs , Acks }}) ->
@@ -1741,7 +1732,7 @@ handle_method(#'tx.rollback'{}, _, State = #ch{unacked_message_q = UAMQ,
17411732 tx = new_tx ()}};
17421733
17431734handle_method (# 'confirm.select' {}, _ , # ch {tx = {_ , _ }}) ->
1744- precondition_failed (" cannot switch from tx to confirm mode" );
1735+ rabbit_misc : precondition_failed (" cannot switch from tx to confirm mode" );
17451736
17461737handle_method (# 'confirm.select' {nowait = NoWait }, _ , State ) ->
17471738 return_ok (State # ch {confirm_enabled = true },
@@ -1762,7 +1753,7 @@ handle_method(#'basic.credit'{consumer_tag = CTag,
17621753 {ok , {Q , _CParams }} ->
17631754 {ok , QStates , Actions } = rabbit_queue_type :credit (Q , CTag , Credit , Drain , QStates0 ),
17641755 {noreply , handle_queue_actions (Actions , State # ch {queue_states = QStates })};
1765- error -> precondition_failed (
1756+ error -> rabbit_misc : precondition_failed (
17661757 " unknown consumer tag '~ts '" , [CTag ])
17671758 end ;
17681759
@@ -2050,7 +2041,7 @@ collect_acks(AcknowledgedAcc, RemainingAcc, UAMQ, DeliveryTag, Multiple) ->
20502041 UAMQTail , DeliveryTag , Multiple )
20512042 end ;
20522043 {empty , _ } ->
2053- precondition_failed (" unknown delivery tag ~w " , [DeliveryTag ])
2044+ rabbit_misc : precondition_failed (" unknown delivery tag ~w " , [DeliveryTag ])
20542045 end .
20552046
20562047% % Settles (acknowledges) messages at the queue replica process level.
@@ -2540,7 +2531,7 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
25402531 undefined ->
25412532 ok ;
25422533 {error , {invalid_type , Type }} ->
2543- precondition_failed (
2534+ rabbit_misc : precondition_failed (
25442535 " invalid type '~ts ' for arg '~ts ' in ~ts " ,
25452536 [Type , DlxKey , rabbit_misc :rs (QueueName )]);
25462537 DLX ->
@@ -2605,35 +2596,7 @@ handle_method(#'queue.delete'{queue = QueueNameBin,
26052596 QueueName = qbin_to_resource (StrippedQueueNameBin , VHostPath ),
26062597
26072598 check_configure_permitted (QueueName , User , AuthzContext ),
2608- case rabbit_amqqueue :with (
2609- QueueName ,
2610- fun (Q ) ->
2611- rabbit_amqqueue :check_exclusive_access (Q , ConnPid ),
2612- rabbit_queue_type :delete (Q , IfUnused , IfEmpty , Username )
2613- end ,
2614- fun (not_found ) ->
2615- {ok , 0 };
2616- ({absent , Q , crashed }) ->
2617- _ = rabbit_classic_queue :delete_crashed (Q , Username ),
2618- {ok , 0 };
2619- ({absent , Q , stopped }) ->
2620- _ = rabbit_classic_queue :delete_crashed (Q , Username ),
2621- {ok , 0 };
2622- ({absent , Q , Reason }) ->
2623- rabbit_amqqueue :absent (Q , Reason )
2624- end ) of
2625- {error , in_use } ->
2626- precondition_failed (" ~ts in use" , [rabbit_misc :rs (QueueName )]);
2627- {error , not_empty } ->
2628- precondition_failed (" ~ts not empty" , [rabbit_misc :rs (QueueName )]);
2629- {error , {exit , _ , _ }} ->
2630- % % rabbit_amqqueue:delete()/delegate:invoke might return {error, {exit, _, _}}
2631- {ok , 0 };
2632- {ok , Count } ->
2633- {ok , Count };
2634- {protocol_error , Type , Reason , ReasonArgs } ->
2635- rabbit_misc :protocol_error (Type , Reason , ReasonArgs )
2636- end ;
2599+ rabbit_amqqueue :delete_with (QueueName , ConnPid , IfUnused , IfEmpty , Username , true );
26372600handle_method (# 'exchange.delete' {exchange = ExchangeNameBin ,
26382601 if_unused = IfUnused },
26392602 _ConnPid , AuthzContext , _CollectorPid , VHostPath ,
@@ -2647,7 +2610,7 @@ handle_method(#'exchange.delete'{exchange = ExchangeNameBin,
26472610 {error , not_found } ->
26482611 ok ;
26492612 {error , in_use } ->
2650- precondition_failed (" ~ts in use" , [rabbit_misc :rs (ExchangeName )]);
2613+ rabbit_misc : precondition_failed (" ~ts in use" , [rabbit_misc :rs (ExchangeName )]);
26512614 ok ->
26522615 ok
26532616 end ;
@@ -2689,7 +2652,7 @@ handle_method(#'exchange.declare'{exchange = ExchangeNameBin,
26892652 case rabbit_misc :r_arg (VHostPath , exchange , Args , AeKey ) of
26902653 undefined -> ok ;
26912654 {error , {invalid_type , Type }} ->
2692- precondition_failed (
2655+ rabbit_misc : precondition_failed (
26932656 " invalid type '~ts ' for arg '~ts ' in ~ts " ,
26942657 [Type , AeKey , rabbit_misc :rs (ExchangeName )]);
26952658 AName -> check_read_permitted (ExchangeName , User , AuthzContext ),
0 commit comments