diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2010-07-08 10:52:05 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2010-07-08 10:52:05 +0100 |
commit | 224507a3477b7b67fbbfadccba08936b0ccd8126 (patch) | |
tree | 6414fa8827bb46efbefb1de0cd8f0ef0836079da | |
parent | ef172ed8f6acb5abbb1538dcd62b7e438aedb4c3 (diff) | |
download | rabbitmq-server-224507a3477b7b67fbbfadccba08936b0ccd8126.tar.gz |
Wrap much less in try / catch
-rw-r--r-- | src/rabbit_channel.erl | 7 | ||||
-rw-r--r-- | src/rabbit_exchange.erl | 36 |
2 files changed, 27 insertions, 16 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 6ad2a3a3..4a13067b 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -909,9 +909,12 @@ binding_action(Fun, ExchangeNameBin, QueueNameBin, RoutingKey, Arguments, State), ExchangeName = rabbit_misc:r(VHostPath, exchange, ExchangeNameBin), check_read_permitted(ExchangeName, State), - case catch Fun(ExchangeName, QueueName, ActualRoutingKey, Arguments, + case Fun(ExchangeName, QueueName, ActualRoutingKey, Arguments, fun (_X, Q) -> - rabbit_amqqueue:check_exclusive_access(Q, ReaderPid) + try + rabbit_amqqueue:check_exclusive_access(Q, ReaderPid) + catch exit:Reason -> {error, Reason} + end end) of {error, exchange_not_found} -> rabbit_misc:not_found(ExchangeName); diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 822c164d..bfe31c13 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -427,16 +427,19 @@ add_binding(ExchangeName, QueueName, RoutingKey, Arguments, InnerFun) -> %% this argument is used to check queue exclusivity; %% in general, we want to fail on that in preference to %% anything else - InnerFun(X, Q), - case mnesia:read({rabbit_route, B}) of - [] -> - sync_binding(B, - X#exchange.durable andalso - Q#amqqueue.durable, - fun mnesia:write/3), - {new, X, B}; - [_R] -> - {existing, X, B} + case InnerFun(X, Q) of + {error, _} = E -> E; + _ -> + case mnesia:read({rabbit_route, B}) of + [] -> + sync_binding(B, + X#exchange.durable andalso + Q#amqqueue.durable, + fun mnesia:write/3), + {new, X, B}; + [_R] -> + {existing, X, B} + end end end) of {new, Exchange = #exchange{ type = Type }, Binding} -> @@ -454,10 +457,15 @@ delete_binding(ExchangeName, QueueName, RoutingKey, Arguments, InnerFun) -> case mnesia:match_object(rabbit_route, #route{binding = B}, write) of [] -> {error, binding_not_found}; - _ -> InnerFun(X, Q), - ok = sync_binding(B, Q#amqqueue.durable, - fun mnesia:delete_object/3), - {maybe_auto_delete(X), B} + _ -> + case InnerFun(X, Q) of + {error, _} = E -> E; + _ -> + ok = + sync_binding(B, Q#amqqueue.durable, + fun mnesia:delete_object/3), + {maybe_auto_delete(X), B} + end end end) of Err = {error, _} -> |