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_text.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_text.erl')
-rw-r--r-- | lib/mnesia/src/mnesia_text.erl | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/mnesia/src/mnesia_text.erl b/lib/mnesia/src/mnesia_text.erl index 0906d18da9..794e633238 100644 --- a/lib/mnesia/src/mnesia_text.erl +++ b/lib/mnesia/src/mnesia_text.erl @@ -84,8 +84,12 @@ validate_tab({Tabname, RecName, List}) -> validate_tab(_) -> error(badtab). make_tabs([{Tab, Def} | Tail]) -> - case catch mnesia:table_info(Tab, where_to_read) of - {'EXIT', _} -> %% non-existing table + try mnesia:table_info(Tab, where_to_read) of + Node -> + io:format("** Table ~w already exists on ~p, just entering data~n", + [Tab, Node]), + make_tabs(Tail) + catch exit:_ -> %% non-existing table case mnesia:create_table(Tab, Def) of {aborted, Reason} -> io:format("** Failed to create table ~w ~n" @@ -95,11 +99,7 @@ make_tabs([{Tab, Def} | Tail]) -> _ -> io:format("New table ~w~n", [Tab]), make_tabs(Tail) - end; - Node -> - io:format("** Table ~w already exists on ~p, just entering data~n", - [Tab, Node]), - make_tabs(Tail) + end end; make_tabs([]) -> @@ -118,11 +118,9 @@ load_data(L) -> parse(File) -> case file(File) of {ok, Terms} -> - case catch collect(Terms) of - {error, X} -> - {error, X}; - Other -> - {ok, Other} + try collect(Terms) of + Other -> {ok, Other} + catch throw:Error -> Error end; Other -> Other |