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 /src/rabbit_exchange.erl | |
parent | ef172ed8f6acb5abbb1538dcd62b7e438aedb4c3 (diff) | |
download | rabbitmq-server-224507a3477b7b67fbbfadccba08936b0ccd8126.tar.gz |
Wrap much less in try / catch
Diffstat (limited to 'src/rabbit_exchange.erl')
-rw-r--r-- | src/rabbit_exchange.erl | 36 |
1 files changed, 22 insertions, 14 deletions
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, _} -> |