@@ -930,15 +930,6 @@ handle_exception(Reason, State = #ch{cfg = #conf{protocol = Protocol,
930
930
{stop , normal , State1 }
931
931
end .
932
932
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
-
942
933
return_queue_declare_ok (# resource {name = ActualName },
943
934
NoWait , MessageCount , ConsumerCount ,
944
935
# ch {cfg = Cfg } = State ) ->
@@ -995,15 +986,15 @@ check_user_id_header(#'P_basic'{user_id = Claimed},
995
986
tags = Tags }}}) ->
996
987
case lists :member (impersonator , Tags ) of
997
988
true -> ok ;
998
- false -> precondition_failed (
989
+ false -> rabbit_misc : precondition_failed (
999
990
" user_id property set to '~ts ' but authenticated user was "
1000
991
" '~ts '" , [Claimed , Actual ])
1001
992
end .
1002
993
1003
994
check_expiration_header (Props ) ->
1004
995
case rabbit_basic :parse_expiration (Props ) of
1005
996
{ok , _ } -> ok ;
1006
- {error , E } -> precondition_failed (" invalid expiration '~ts ': ~tp " ,
997
+ {error , E } -> rabbit_misc : precondition_failed (" invalid expiration '~ts ': ~tp " ,
1007
998
[Props # 'P_basic' .expiration , E ])
1008
999
end .
1009
1000
@@ -1074,15 +1065,15 @@ check_msg_size(Content, MaxMessageSize, GCThreshold) ->
1074
1065
_ ->
1075
1066
" message size ~B is larger than configured max size ~B "
1076
1067
end ,
1077
- precondition_failed (ErrorMessage ,
1068
+ rabbit_misc : precondition_failed (ErrorMessage ,
1078
1069
[Size , MaxMessageSize ]);
1079
1070
_ -> ok
1080
1071
end .
1081
1072
1082
1073
check_vhost_queue_limit (# resource {name = QueueName }, VHost ) ->
1083
1074
case rabbit_vhost_limit :is_over_queue_limit (VHost ) of
1084
1075
false -> ok ;
1085
- {true , Limit } -> precondition_failed (" cannot declare queue '~ts ': "
1076
+ {true , Limit } -> rabbit_misc : precondition_failed (" cannot declare queue '~ts ': "
1086
1077
" queue limit in vhost '~ts ' (~tp ) is reached" ,
1087
1078
[QueueName , VHost , Limit ])
1088
1079
@@ -1704,7 +1695,7 @@ handle_method(#'queue.purge'{nowait = NoWait} = Method,
1704
1695
end ;
1705
1696
1706
1697
handle_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" );
1708
1699
1709
1700
handle_method (# 'tx.select' {}, _ , State = # ch {tx = none }) ->
1710
1701
{reply , # 'tx.select_ok' {}, State # ch {tx = new_tx ()}};
@@ -1713,7 +1704,7 @@ handle_method(#'tx.select'{}, _, State) ->
1713
1704
{reply , # 'tx.select_ok' {}, State };
1714
1705
1715
1706
handle_method (# 'tx.commit' {}, _ , # ch {tx = none }) ->
1716
- precondition_failed (" channel is not transactional" );
1707
+ rabbit_misc : precondition_failed (" channel is not transactional" );
1717
1708
1718
1709
handle_method (# 'tx.commit' {}, _ , State = # ch {tx = {Deliveries , Acks },
1719
1710
limiter = Limiter }) ->
@@ -1731,7 +1722,7 @@ handle_method(#'tx.commit'{}, _, State = #ch{tx = {Deliveries, Acks},
1731
1722
{noreply , maybe_complete_tx (State3 # ch {tx = committing })};
1732
1723
1733
1724
handle_method (# 'tx.rollback' {}, _ , # ch {tx = none }) ->
1734
- precondition_failed (" channel is not transactional" );
1725
+ rabbit_misc : precondition_failed (" channel is not transactional" );
1735
1726
1736
1727
handle_method (# 'tx.rollback' {}, _ , State = # ch {unacked_message_q = UAMQ ,
1737
1728
tx = {_Msgs , Acks }}) ->
@@ -1741,7 +1732,7 @@ handle_method(#'tx.rollback'{}, _, State = #ch{unacked_message_q = UAMQ,
1741
1732
tx = new_tx ()}};
1742
1733
1743
1734
handle_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" );
1745
1736
1746
1737
handle_method (# 'confirm.select' {nowait = NoWait }, _ , State ) ->
1747
1738
return_ok (State # ch {confirm_enabled = true },
@@ -1762,7 +1753,7 @@ handle_method(#'basic.credit'{consumer_tag = CTag,
1762
1753
{ok , {Q , _CParams }} ->
1763
1754
{ok , QStates , Actions } = rabbit_queue_type :credit (Q , CTag , Credit , Drain , QStates0 ),
1764
1755
{noreply , handle_queue_actions (Actions , State # ch {queue_states = QStates })};
1765
- error -> precondition_failed (
1756
+ error -> rabbit_misc : precondition_failed (
1766
1757
" unknown consumer tag '~ts '" , [CTag ])
1767
1758
end ;
1768
1759
@@ -2050,7 +2041,7 @@ collect_acks(AcknowledgedAcc, RemainingAcc, UAMQ, DeliveryTag, Multiple) ->
2050
2041
UAMQTail , DeliveryTag , Multiple )
2051
2042
end ;
2052
2043
{empty , _ } ->
2053
- precondition_failed (" unknown delivery tag ~w " , [DeliveryTag ])
2044
+ rabbit_misc : precondition_failed (" unknown delivery tag ~w " , [DeliveryTag ])
2054
2045
end .
2055
2046
2056
2047
% % Settles (acknowledges) messages at the queue replica process level.
@@ -2540,7 +2531,7 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
2540
2531
undefined ->
2541
2532
ok ;
2542
2533
{error , {invalid_type , Type }} ->
2543
- precondition_failed (
2534
+ rabbit_misc : precondition_failed (
2544
2535
" invalid type '~ts ' for arg '~ts ' in ~ts " ,
2545
2536
[Type , DlxKey , rabbit_misc :rs (QueueName )]);
2546
2537
DLX ->
@@ -2605,35 +2596,7 @@ handle_method(#'queue.delete'{queue = QueueNameBin,
2605
2596
QueueName = qbin_to_resource (StrippedQueueNameBin , VHostPath ),
2606
2597
2607
2598
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 );
2637
2600
handle_method (# 'exchange.delete' {exchange = ExchangeNameBin ,
2638
2601
if_unused = IfUnused },
2639
2602
_ConnPid , AuthzContext , _CollectorPid , VHostPath ,
@@ -2647,7 +2610,7 @@ handle_method(#'exchange.delete'{exchange = ExchangeNameBin,
2647
2610
{error , not_found } ->
2648
2611
ok ;
2649
2612
{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 )]);
2651
2614
ok ->
2652
2615
ok
2653
2616
end ;
@@ -2689,7 +2652,7 @@ handle_method(#'exchange.declare'{exchange = ExchangeNameBin,
2689
2652
case rabbit_misc :r_arg (VHostPath , exchange , Args , AeKey ) of
2690
2653
undefined -> ok ;
2691
2654
{error , {invalid_type , Type }} ->
2692
- precondition_failed (
2655
+ rabbit_misc : precondition_failed (
2693
2656
" invalid type '~ts ' for arg '~ts ' in ~ts " ,
2694
2657
[Type , AeKey , rabbit_misc :rs (ExchangeName )]);
2695
2658
AName -> check_read_permitted (ExchangeName , User , AuthzContext ),
0 commit comments