diff options
| author | Matthias Radestock <matthias@lshift.net> | 2009-05-20 21:09:08 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2009-05-20 21:09:08 +0100 |
| commit | 3120cdcb7b8f903c7236c636578ddabeb50068fd (patch) | |
| tree | 94d81a756e3f4debcb5a219979ef5096caa70c97 /src | |
| parent | d94afdb18a980fb13c23a2cf8077de4f332f383f (diff) | |
| download | rabbitmq-server-git-3120cdcb7b8f903c7236c636578ddabeb50068fd.tar.gz | |
helper method for not_found errors
There was enough repetition to make it worthwhile
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_amqqueue.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_channel.erl | 9 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 4 |
4 files changed, 9 insertions, 12 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index eb076e94d6..0316788fe1 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -201,9 +201,7 @@ with(Name, F, E) -> with(Name, F) -> with(Name, F, fun () -> {error, not_found} end). with_or_die(Name, F) -> - with(Name, F, fun () -> rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(Name)]) - end). + with(Name, F, fun () -> rabbit_misc:not_found(Name) end). list(VHostPath) -> mnesia:dirty_match_object( diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index b2716ec478..e837c84fde 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -579,8 +579,7 @@ handle_method(#'exchange.delete'{exchange = ExchangeNameBin, check_configure_permitted(ExchangeName, State), case rabbit_exchange:delete(ExchangeName, IfUnused) of {error, not_found} -> - rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(ExchangeName)]); + rabbit_misc:not_found(ExchangeName); {error, in_use} -> die_precondition_failed( "~s in use", [rabbit_misc:rs(ExchangeName)]); @@ -746,11 +745,9 @@ binding_action(Fun, ExchangeNameBin, QueueNameBin, RoutingKey, Arguments, check_read_permitted(ExchangeName, State), case Fun(ExchangeName, QueueName, ActualRoutingKey, Arguments) of {error, exchange_not_found} -> - rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(ExchangeName)]); + rabbit_misc:not_found(ExchangeName); {error, queue_not_found} -> - rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(QueueName)]); + rabbit_misc:not_found(QueueName); {error, exchange_and_queue_not_found} -> rabbit_misc:protocol_error( not_found, "no ~s and no ~s", [rabbit_misc:rs(ExchangeName), diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index fc89cfca51..d6d70cba38 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -164,9 +164,7 @@ lookup(Name) -> lookup_or_die(Name) -> case lookup(Name) of {ok, X} -> X; - {error, not_found} -> - rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(Name)]) + {error, not_found} -> rabbit_misc:not_found(Name) end. list(VHostPath) -> diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index eced0b3cbe..7a395a6feb 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -36,6 +36,7 @@ -export([method_record_type/1, polite_pause/0, polite_pause/1]). -export([die/1, frame_error/2, protocol_error/3, protocol_error/4]). +-export([not_found/1]). -export([get_config/1, get_config/2, set_config/2]). -export([dirty_read/1]). -export([r/3, r/2, rs/1]). @@ -72,6 +73,7 @@ (atom() | amqp_error(), string(), [any()]) -> no_return()). -spec(protocol_error/4 :: (atom() | amqp_error(), string(), [any()], atom()) -> no_return()). +-spec(not_found/1 :: (r(atom())) -> no_return()). -spec(get_config/1 :: (atom()) -> {'ok', any()} | not_found()). -spec(get_config/2 :: (atom(), A) -> A). -spec(set_config/2 :: (atom(), any()) -> 'ok'). @@ -139,6 +141,8 @@ protocol_error(Error, Explanation, Params, Method) -> CompleteExplanation = lists:flatten(io_lib:format(Explanation, Params)), exit({amqp, Error, CompleteExplanation, Method}). +not_found(R) -> protocol_error(not_found, "no ~s", [rs(R)]). + get_config(Key) -> case dirty_read({rabbit_config, Key}) of {ok, {rabbit_config, Key, V}} -> {ok, V}; |
