diff options
author | Dan Gudmundsson <[email protected]> | 2014-04-29 10:09:08 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2015-03-27 13:15:24 +0100 |
commit | a83bf960f1018217d7f3c9c8387a37722aa93fc6 (patch) | |
tree | fddad434266d4af2e4835d4b071be9a4c798f5ec /lib/mnesia/src/mnesia_subscr.erl | |
parent | bb7642ee5f326b25425634cfc40baa385f5ab3fa (diff) | |
download | otp-a83bf960f1018217d7f3c9c8387a37722aa93fc6.tar.gz otp-a83bf960f1018217d7f3c9c8387a37722aa93fc6.tar.bz2 otp-a83bf960f1018217d7f3c9c8387a37722aa93fc6.zip |
mnesia: Replace catch with try-catch
Avoids building stacktraces where it is not needed and do
not mask errors, i.e. only catch the relevant classes in each try.
Diffstat (limited to 'lib/mnesia/src/mnesia_subscr.erl')
-rw-r--r-- | lib/mnesia/src/mnesia_subscr.erl | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/mnesia/src/mnesia_subscr.erl b/lib/mnesia/src/mnesia_subscr.erl index 9272211ad2..9cf955b4d3 100644 --- a/lib/mnesia/src/mnesia_subscr.erl +++ b/lib/mnesia/src/mnesia_subscr.erl @@ -186,11 +186,11 @@ patch_record(Tab, Obj) -> end. what(Tab, Tid, {RecName, Key}, delete, undefined) -> - case catch mnesia_lib:db_get(Tab, Key) of - Old when is_list(Old) -> %% Op only allowed for set table. - {mnesia_table_event, {delete, Tab, {RecName, Key}, Old, Tid}}; - _ -> - %% Record just deleted by a dirty_op or + try mnesia_lib:db_get(Tab, Key) of + Old -> %% Op only allowed for set table. + {mnesia_table_event, {delete, Tab, {RecName, Key}, Old, Tid}} + catch error:_ -> + %% Record just deleted by a dirty_op or %% the whole table has been deleted ignore end; @@ -199,10 +199,10 @@ what(Tab, Tid, Obj, delete, Old) -> what(Tab, Tid, Obj, delete_object, _Old) -> {mnesia_table_event, {delete, Tab, Obj, [Obj], Tid}}; what(Tab, Tid, Obj, write, undefined) -> - case catch mnesia_lib:db_get(Tab, element(2, Obj)) of - Old when is_list(Old) -> - {mnesia_table_event, {write, Tab, Obj, Old, Tid}}; - {'EXIT', _} -> + try mnesia_lib:db_get(Tab, element(2, Obj)) of + Old -> + {mnesia_table_event, {write, Tab, Obj, Old, Tid}} + catch error:_ -> ignore end; what(Tab, Tid, Obj, write, Old) -> @@ -386,12 +386,12 @@ activate(ClientPid, What, Var, OldSubscribers, SubscrTab) -> case lists:member(ClientPid, Old) of false -> %% Don't care about checking old links - case catch link(ClientPid) of + try link(ClientPid) of true -> ?ets_insert(SubscrTab, {ClientPid, What}), add_subscr(Var, What, ClientPid), - {ok, node()}; - {'EXIT', _Reason} -> + {ok, node()} + catch error:_ -> {error, {no_exists, ClientPid}} end; true -> @@ -443,11 +443,10 @@ add_subscr({Tab, commit_work}, What, Pid) -> deactivate(ClientPid, What, Var, SubscrTab) -> ?ets_match_delete(SubscrTab, {ClientPid, What}), - case catch ?ets_lookup_element(SubscrTab, ClientPid, 1) of - List when is_list(List) -> - ignore; - {'EXIT', _} -> - unlink(ClientPid) + try + ?ets_lookup_element(SubscrTab, ClientPid, 1), + ignore + catch error:_ -> unlink(ClientPid) end, try del_subscr(Var, What, ClientPid), |