diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-09 05:14:17 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-09 05:14:17 +0100 |
| commit | 279c8ed54b8ef1eee5cba54fb90692722e923768 (patch) | |
| tree | 287ca52846433eb3a7d2c280ac5e032a8e32c15a /src | |
| parent | 03ab56687cd0f959c5a47906430a6e1182055f05 (diff) | |
| download | rabbitmq-server-git-279c8ed54b8ef1eee5cba54fb90692722e923768.tar.gz | |
refactor: introduce rabbit_misc:protocol_error/1
so that the channel can get away with knowing a little bit less about
error handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_channel.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 9a02e2bd13..c4db3ace73 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -928,10 +928,8 @@ binding_action(Fun, ExchangeNameBin, QueueNameBin, RoutingKey, Arguments, not_found, "no binding ~s between ~s and ~s", [RoutingKey, rabbit_misc:rs(ExchangeName), rabbit_misc:rs(QueueName)]); - %% When check_exclusive_access exits with a protocol error this gets - %% wrapped by mnesia. Unwrap it and exit again. {error, #amqp_error{} = Error} -> - exit(Error); + rabbit_misc:protocol_error(Error); ok -> return_ok(State, NoWait, ReturnMethod) end. diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index f04df8a042..fcc9fc7e54 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -37,7 +37,7 @@ -export([method_record_type/1, polite_pause/0, polite_pause/1]). -export([die/1, frame_error/2, amqp_error/4, - protocol_error/3, protocol_error/4]). + protocol_error/3, protocol_error/4, protocol_error/1]). -export([not_found/1]). -export([get_config/1, get_config/2, set_config/2]). -export([dirty_read/1]). @@ -95,6 +95,7 @@ (rabbit_framing:amqp_exception(), string(), [any()], rabbit_framing:amqp_method_name()) -> no_return()). +-spec(protocol_error/1 :: (rabbit_types:amqp_error()) -> no_return()). -spec(not_found/1 :: (rabbit_types:r(atom())) -> no_return()). -spec(get_config/1 :: (atom()) -> rabbit_types:ok_or_error2(any(), 'not_found')). @@ -199,7 +200,10 @@ protocol_error(Name, ExplanationFormat, Params) -> protocol_error(Name, ExplanationFormat, Params, none). protocol_error(Name, ExplanationFormat, Params, Method) -> - exit(amqp_error(Name, ExplanationFormat, Params, Method)). + protocol_error(amqp_error(Name, ExplanationFormat, Params, Method)). + +protocol_error(#amqp_error{} = Error) -> + exit(Error). not_found(R) -> protocol_error(not_found, "no ~s", [rs(R)]). |
