@@ -751,18 +751,27 @@ map_exception(Channel, Reason) ->
751751 end ,
752752 {ShouldClose , CloseChannel , CloseMethod }.
753753
754- lookup_amqp_exception (
755- # amqp_error {name = Name , explanation = Expl , method = Method }) ->
754+ % % FIXME: this clause can go when we move to AMQP spec >=8.1
755+ lookup_amqp_exception (# amqp_error {name = precondition_failed ,
756+ explanation = Expl ,
757+ method = Method }) ->
758+ ExplBin = amqp_exception_explanation (<<" PRECONDITION_FAILED" >>, Expl ),
759+ {false , 406 , ExplBin , Method };
760+ lookup_amqp_exception (# amqp_error {name = Name ,
761+ explanation = Expl ,
762+ method = Method }) ->
756763 {ShouldClose , Code , Text } = rabbit_framing :lookup_amqp_exception (Name ),
757- ExplBin = list_to_binary (Expl ),
758- CompleteTextBin = <<Text /binary , " - " , ExplBin /binary >>,
759- SafeTextBin = if size (CompleteTextBin ) > 255 ->
760- <<CompleteTextBin :252 /binary , " ..." >>;
761- true -> CompleteTextBin
762- end ,
763- {ShouldClose , Code , SafeTextBin , Method };
764+ ExplBin = amqp_exception_explanation (Text , Expl ),
765+ {ShouldClose , Code , ExplBin , Method };
764766lookup_amqp_exception (Other ) ->
765767 rabbit_log :warning (" Non-AMQP exit reason '~p '~n " , [Other ]),
766768 {ShouldClose , Code , Text } =
767769 rabbit_framing :lookup_amqp_exception (internal_error ),
768770 {ShouldClose , Code , Text , none }.
771+
772+ amqp_exception_explanation (Text , Expl ) ->
773+ ExplBin = list_to_binary (Expl ),
774+ CompleteTextBin = <<Text /binary , " - " , ExplBin /binary >>,
775+ if size (CompleteTextBin ) > 255 -> <<CompleteTextBin :252 /binary , " ..." >>;
776+ true -> CompleteTextBin
777+ end .
0 commit comments