|
35 | 35 | -include_lib("kernel/include/file.hrl"). |
36 | 36 |
|
37 | 37 | -export([method_record_type/1, polite_pause/0, polite_pause/1]). |
38 | | --export([die/1, frame_error/2, protocol_error/3, protocol_error/4]). |
| 38 | +-export([die/1, frame_error/2, amqp_error/4, protocol_error/3, protocol_error/4]). |
39 | 39 | -export([not_found/1]). |
40 | 40 | -export([get_config/1, get_config/2, set_config/2]). |
41 | 41 | -export([dirty_read/1]). |
|
74 | 74 | -spec(polite_pause/1 :: (non_neg_integer()) -> 'done'). |
75 | 75 | -spec(die/1 :: (atom()) -> no_return()). |
76 | 76 | -spec(frame_error/2 :: (atom(), binary()) -> no_return()). |
77 | | --spec(protocol_error/3 :: |
78 | | - (atom() | amqp_error(), string(), [any()]) -> no_return()). |
79 | | --spec(protocol_error/4 :: |
80 | | - (atom() | amqp_error(), string(), [any()], atom()) -> no_return()). |
| 77 | +-spec(amqp_error/4 :: (atom(), string(), [any()], atom()) -> amqp_error()). |
| 78 | +-spec(protocol_error/3 :: (atom(), string(), [any()]) -> no_return()). |
| 79 | +-spec(protocol_error/4 :: (atom(), string(), [any()], atom()) -> no_return()). |
81 | 80 | -spec(not_found/1 :: (r(atom())) -> no_return()). |
82 | 81 | -spec(get_config/1 :: (atom()) -> {'ok', any()} | not_found()). |
83 | 82 | -spec(get_config/2 :: (atom(), A) -> A). |
@@ -144,15 +143,17 @@ die(Error) -> |
144 | 143 | protocol_error(Error, "~w", [Error]). |
145 | 144 |
|
146 | 145 | frame_error(MethodName, BinaryFields) -> |
147 | | - protocol_error(frame_error, "cannot decode ~w", |
148 | | - [BinaryFields], MethodName). |
| 146 | + protocol_error(frame_error, "cannot decode ~w", [BinaryFields], MethodName). |
149 | 147 |
|
150 | | -protocol_error(Error, Explanation, Params) -> |
151 | | - protocol_error(Error, Explanation, Params, none). |
| 148 | +amqp_error(Name, Explanation, Params, Method) -> |
| 149 | + #amqp_error{name = Name, |
| 150 | + expl = lists:flatten(io_lib:format(Explanation, Params)), |
| 151 | + method = Method}. |
152 | 152 |
|
153 | | -protocol_error(Error, Explanation, Params, Method) -> |
154 | | - CompleteExplanation = lists:flatten(io_lib:format(Explanation, Params)), |
155 | | - exit({amqp, Error, CompleteExplanation, Method}). |
| 153 | +protocol_error(Name, Explanation, Params) -> |
| 154 | + protocol_error(Name, Explanation, Params, none). |
| 155 | +protocol_error(Name, Explanation, Params, Method) -> |
| 156 | + exit(amqp_error(Name, Explanation, Params, Method)). |
156 | 157 |
|
157 | 158 | not_found(R) -> protocol_error(not_found, "no ~s", [rs(R)]). |
158 | 159 |
|
|
0 commit comments