diff options
| author | Matthias Radestock <matthias@lshift.net> | 2009-04-23 12:46:38 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2009-04-23 12:46:38 +0100 |
| commit | c06b2f49952d1aa497c34dd46906190c4a69fd2f (patch) | |
| tree | d309aa33e23c091dcb93ea40e14c0eb8a205e2a9 | |
| parent | 040746724b76cc79c4816439d2cabc44a44740b9 (diff) | |
| download | rabbitmq-server-git-c06b2f49952d1aa497c34dd46906190c4a69fd2f.tar.gz | |
return the correct error (not_found) on exchange deletion
in the process discriminate more on 'unbind' errors
| -rw-r--r-- | src/rabbit_channel.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 22 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 4bf2f44602..5fd9a512db 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -664,12 +664,16 @@ binding_action(Fun, ExchangeNameBin, QueueNameBin, RoutingKey, Arguments, State), ExchangeName = rabbit_misc:r(VHostPath, exchange, ExchangeNameBin), case Fun(ExchangeName, QueueName, ActualRoutingKey, Arguments) of + {error, exchange_not_found} -> + rabbit_misc:protocol_error( + not_found, "no ~s", [rabbit_misc:rs(ExchangeName)]); {error, queue_not_found} -> rabbit_misc:protocol_error( not_found, "no ~s", [rabbit_misc:rs(QueueName)]); - {error, exchange_not_found} -> + {error, exchange_and_queue_not_found} -> rabbit_misc:protocol_error( - not_found, "no ~s", [rabbit_misc:rs(ExchangeName)]); + not_found, "no ~s and no ~s", [rabbit_misc:rs(ExchangeName), + rabbit_misc:rs(QueueName)]); {error, binding_not_found} -> rabbit_misc:protocol_error( not_found, "no binding ~s between ~s and ~s", diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index b70b868d1b..89e828d75e 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -59,8 +59,10 @@ -type(publish_res() :: {'ok', [pid()]} | not_found() | {'error', 'unroutable' | 'not_delivered'}). --type(bind_res() :: 'ok' | - {'error', 'queue_not_found' | 'exchange_not_found'}). +-type(bind_res() :: 'ok' | {'error', + 'queue_not_found' | + 'exchange_not_found' | + 'exchange_and_queue_not_found'}). -spec(recover/0 :: () -> 'ok'). -spec(declare/5 :: (exchange_name(), exchange_type(), bool(), bool(), amqp_table()) -> exchange()). @@ -340,18 +342,20 @@ continue({[], Continuation}) -> continue(mnesia:select(Continuation)). call_with_exchange(Exchange, Fun) -> rabbit_misc:execute_mnesia_transaction( fun() -> case mnesia:read({exchange, Exchange}) of - [] -> {error, exchange_not_found}; + [] -> {error, not_found}; [X] -> Fun(X) end end). call_with_exchange_and_queue(Exchange, Queue, Fun) -> - call_with_exchange( - Exchange, - fun(X) -> case mnesia:read({amqqueue, Queue}) of - [] -> {error, queue_not_found}; - [Q] -> Fun(X, Q) - end + rabbit_misc:execute_mnesia_transaction( + fun() -> case {mnesia:read({exchange, Exchange}), + mnesia:read({amqqueue, Queue})} of + {[X], [Q]} -> Fun(X, Q); + {[ ], [_]} -> {error, exchange_not_found}; + {[_], [ ]} -> {error, queue_not_found}; + {[ ], [ ]} -> {error, exchange_and_queue_not_found} + end end). add_binding(ExchangeName, QueueName, RoutingKey, Arguments) -> |
