diff --git a/apps/rebar/src/rebar_packages.erl b/apps/rebar/src/rebar_packages.erl index 9f47911f6..cd43fc52a 100644 --- a/apps/rebar/src/rebar_packages.erl +++ b/apps/rebar/src/rebar_packages.erl @@ -116,7 +116,7 @@ load_and_verify_version(State) -> %% shouldn't notice, so log as a debug message only ?DEBUG("Package index version mismatch. Current version ~p, this rebar3 expecting ~p", [V, ?PACKAGE_INDEX_VERSION]), - (catch ets:delete(?PACKAGE_TABLE)), + try ets:delete(?PACKAGE_TABLE) catch _:_ -> ok end, new_package_table() end; _ -> diff --git a/apps/rebar/src/rebar_pkg_resource.erl b/apps/rebar/src/rebar_pkg_resource.erl index d7d4f25a1..fc09c0365 100644 --- a/apps/rebar/src/rebar_pkg_resource.erl +++ b/apps/rebar/src/rebar_pkg_resource.erl @@ -280,7 +280,7 @@ maybe_old_registry_checksum(Hash) -> list_to_integer(binary_to_list(Hash), 16). Binary :: binary(), Res :: ok | {error,_}. serve_from_download(TmpDir, CachePath, Package, Binary) -> - ?DEBUG("Writing ~p to cache at ~ts", [catch anon(Package), CachePath]), + ?DEBUG("Writing ~p to cache at ~ts", [try anon(Package) catch _:_ -> error end, CachePath]), file:write_file(CachePath, Binary), serve_from_memory(TmpDir, Binary, Package). diff --git a/apps/rebar/src/rebar_prv_cover.erl b/apps/rebar/src/rebar_prv_cover.erl index 9022571bc..38c30ddf2 100644 --- a/apps/rebar/src/rebar_prv_cover.erl +++ b/apps/rebar/src/rebar_prv_cover.erl @@ -359,7 +359,9 @@ is_ignored(Dir, File, ExclMods) -> Ignored. cover_compile_file(FileName) -> - case catch(cover:compile_beam(FileName)) of + case try cover:compile_beam(FileName) + catch C:R -> {'EXIT', {C, R}} + end of {error, Reason} -> ?WARN("Cover compilation failed: ~p", [Reason]); {ok, _} -> diff --git a/apps/rebar/src/rebar_prv_edoc.erl b/apps/rebar/src/rebar_prv_edoc.erl index c7782d22d..7904b599a 100644 --- a/apps/rebar/src/rebar_prv_edoc.erl +++ b/apps/rebar/src/rebar_prv_edoc.erl @@ -49,7 +49,10 @@ do(State) -> %% order of the merge is important to allow app opts overrides AppEdocOpts = merge_opts(rebar_opts:get(AppOpts, edoc_opts, []), EdocOptsAcc), ?DEBUG("{edoc_opts, ~p}.", [AppEdocOpts]), - AppRes = (catch edoc:application(list_to_atom(AppName), AppDir, AppEdocOpts)), + AppRes = + try edoc:application(list_to_atom(AppName), AppDir, AppEdocOpts) + catch _:_ -> error + end, rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo, State), case {AppRes, ShouldAccPaths} of {ok, true} -> @@ -57,7 +60,7 @@ do(State) -> add_to_paths(EdocOptsAcc, AppDir++"/doc"); {ok, false} -> EdocOptsAcc; - {{'EXIT', error}, _} -> + {error, _} -> %% EDoc is not very descriptive %% in terms of failures throw({app_failed, AppName}) diff --git a/apps/rebar/src/rebar_prv_shell.erl b/apps/rebar/src/rebar_prv_shell.erl index 587162aa2..cea46e4fc 100644 --- a/apps/rebar/src/rebar_prv_shell.erl +++ b/apps/rebar/src/rebar_prv_shell.erl @@ -246,7 +246,7 @@ rewrite_leaders(OldUser, NewUser) -> %% set any process that had a reference to the old user's group leader to the %% new user process. Catch the race condition when the Pid exited after the %% liveness check. - _ = [catch erlang:group_leader(NewUser, Pid) + _ = [try erlang:group_leader(NewUser, Pid) catch _:_ -> ok end || Pid <- erlang:processes(), [_|_] = Info <- [erlang:process_info(Pid)], proplists:get_value(group_leader, Info) == OldUser, @@ -260,7 +260,7 @@ rewrite_leaders(OldUser, NewUser) -> Pid < NewUser, % only change old masters {_,Dict} <- [erlang:process_info(Pid, dictionary)], {application_master,init,4} == proplists:get_value('$initial_call', Dict)], - _ = [catch erlang:group_leader(NewUser, Pid) + _ = [try erlang:group_leader(NewUser, Pid) catch _:_ -> ok end || Pid <- erlang:processes(), lists:member(proplists:get_value(group_leader, erlang:process_info(Pid)), OldMasters)], diff --git a/apps/rebar/src/rebar_user.erl b/apps/rebar/src/rebar_user.erl index f20142dc1..bd81bc57f 100644 --- a/apps/rebar/src/rebar_user.erl +++ b/apps/rebar/src/rebar_user.erl @@ -99,7 +99,7 @@ catch_loop(Port, Shell) -> catch_loop(Port, Shell, queue:new()). catch_loop(Port, Shell, Q) -> - case catch server_loop(Port, Q) of + case catcher(fun() -> server_loop(Port, Q) end) of new_shell -> exit(Shell, kill), catch_loop(Port, start_new_shell()); @@ -170,12 +170,15 @@ server_loop(Port, Q) -> get_fd_geometry(Port) -> - case (catch port_control(Port,?CTRL_OP_GET_WINSIZE,[])) of + try port_control(Port,?CTRL_OP_GET_WINSIZE,[]) of List when length(List) =:= 8 -> <> = list_to_binary(List), {W,H}; _ -> error + catch + _:_ -> + error end. @@ -201,7 +204,7 @@ io_request({put_chars,unicode,Chars}, Port, Q) -> % Binary new in R9C put_chars(Bin, Port, Q) end; io_request({put_chars,unicode,Mod,Func,Args}, Port, Q) -> - case catch apply(Mod,Func,Args) of + case catcher(fun() -> apply(Mod,Func,Args) end) of Data when is_list(Data); is_binary(Data) -> case wrap_characters_to_binary(Data, unicode, get(encoding)) of Bin when is_binary(Bin) -> @@ -213,17 +216,17 @@ io_request({put_chars,unicode,Mod,Func,Args}, Port, Q) -> put_chars(Undef, Port, Q) end; io_request({put_chars,latin1,Chars}, Port, Q) -> % Binary new in R9C - case catch unicode:characters_to_binary(Chars, latin1, get(encoding)) of + case wrap_unicode_characters_to_binary(Chars, latin1, get(encoding)) of Data when is_binary(Data) -> put_chars(Data, Port, Q); _ -> {error,{error,put_chars},Q} end; io_request({put_chars,latin1,Mod,Func,Args}, Port, Q) -> - case catch apply(Mod,Func,Args) of + case catcher(fun() -> apply(Mod,Func,Args) end) of Data when is_list(Data); is_binary(Data) -> case - catch unicode:characters_to_binary(Data,latin1,get(encoding)) + wrap_unicode_characters_to_binary(Data,latin1,get(encoding)) of Bin when is_binary(Bin) -> put_chars(Bin, Port, Q); @@ -317,10 +320,10 @@ put_chars(Chars, Port, Q) when is_binary(Chars) -> ok = put_port(Chars, Port), {ok,ok,Q}; put_chars(Chars, Port, Q) -> - case catch list_to_binary(Chars) of - Binary when is_binary(Binary) -> - put_chars(Binary, Port, Q); - _ -> + try list_to_binary(Chars) of + Binary -> + put_chars(Binary, Port, Q) + catch _:_ -> {error,{error,put_chars},Q} end. @@ -603,7 +606,7 @@ get_chars_bytes(State, M, F, Xa, Port, Q, Bytes, Enc) -> end. get_chars_apply(State0, M, F, Xa, Port, Q, Enc) -> - case catch M:F(State0, cast(queue:head(Q),Enc), Enc, Xa) of + case catcher(fun() -> M:F(State0, cast(queue:head(Q),Enc), Enc, Xa) end) of {stop,Result,<<>>} -> {ok,Result,queue:tail(Q)}; {stop,Result,[]} -> @@ -676,36 +679,36 @@ cast(Data, Encoding) -> cast(B, binary, latin1, latin1) when is_binary(B) -> B; cast(L, binary, latin1, latin1) -> - case catch erlang:iolist_to_binary(L) of + case wrap_erlang_iolist_to_binary(L) of Bin when is_binary(Bin) -> Bin; _ -> exit({no_translation, latin1, latin1}) end; cast(Data, binary, unicode, latin1) when is_binary(Data); is_list(Data) -> - case catch unicode:characters_to_binary(Data, unicode, latin1) of + case wrap_unicode_characters_to_binary(Data, unicode, latin1) of Bin when is_binary(Bin) -> Bin; _ -> exit({no_translation, unicode, latin1}) end; cast(Data, binary, latin1, unicode) when is_binary(Data); is_list(Data) -> - case catch unicode:characters_to_binary(Data, latin1, unicode) of + case wrap_unicode_characters_to_binary(Data, latin1, unicode) of Bin when is_binary(Bin) -> Bin; _ -> exit({no_translation, latin1, unicode}) end; cast(B, binary, unicode, unicode) when is_binary(B) -> B; cast(L, binary, unicode, unicode) -> - case catch unicode:characters_to_binary(L, unicode) of + case wrap_unicode_characters_to_binary(L, unicode, unicode) of Bin when is_binary(Bin) -> Bin; _ -> exit({no_translation, unicode, unicode}) end; cast(B, list, latin1, latin1) when is_binary(B) -> binary_to_list(B); cast(L, list, latin1, latin1) -> - case catch erlang:iolist_to_binary(L) of + case wrap_erlang_iolist_to_binary(L) of Bin when is_binary(Bin) -> binary_to_list(Bin); _ -> exit({no_translation, latin1, latin1}) end; cast(Data, list, unicode, latin1) when is_binary(Data); is_list(Data) -> - case catch unicode:characters_to_list(Data, unicode) of + case wrap_unicode_characters_to_list(Data, unicode) of Chars when is_list(Chars) -> [ case X of High when High > 255 -> @@ -717,22 +720,22 @@ cast(Data, list, unicode, latin1) when is_binary(Data); is_list(Data) -> exit({no_translation, unicode, latin1}) end; cast(Data, list, latin1, unicode) when is_binary(Data); is_list(Data) -> - case catch unicode:characters_to_list(Data, latin1) of + case wrap_unicode_characters_to_list(Data, latin1) of Chars when is_list(Chars) -> Chars; _ -> exit({no_translation, latin1, unicode}) end; cast(Data, list, unicode, unicode) when is_binary(Data); is_list(Data) -> - case catch unicode:characters_to_list(Data, unicode) of + case wrap_unicode_characters_to_list(Data, unicode) of Chars when is_list(Chars) -> Chars; _ -> exit({no_translation, unicode, unicode}) end. wrap_characters_to_binary(Chars, unicode, latin1) -> - case catch unicode:characters_to_binary(Chars, unicode, latin1) of + case wrap_unicode_characters_to_binary(Chars, unicode, latin1) of Bin when is_binary(Bin) -> Bin; _ -> - case catch unicode:characters_to_list(Chars, unicode) of + case wrap_unicode_characters_to_list(Chars, unicode) of L when is_list(L) -> list_to_binary( [ case X of @@ -748,10 +751,33 @@ wrap_characters_to_binary(Chars, unicode, latin1) -> wrap_characters_to_binary(Bin, From, From) when is_binary(Bin) -> Bin; wrap_characters_to_binary(Chars, From, To) -> - case catch unicode:characters_to_binary(Chars, From, To) of + case wrap_unicode_characters_to_binary(Chars, From, To) of Bin when is_binary(Bin) -> Bin; _ -> error end. +wrap_erlang_iolist_to_binary(L) -> + try erlang:iolist_to_binary(L) + catch _:_ -> error + end. + +wrap_unicode_characters_to_binary(Chars, InEncoding, OutEncoding) -> + try unicode:characters_to_binary(Chars, InEncoding, OutEncoding) + catch _:_ -> error + end. + +wrap_unicode_characters_to_list(Chars, InEncoding) -> + try unicode:characters_to_list(Chars, InEncoding) + catch _:_ -> error + end. + +%% This module has "interesting" control-flow, so where it's not obvious that +%% it's not needed, we use this emulation of old-style catches. +catcher(Fun) -> + try Fun() + catch throw:Result -> Result; + error:Reason:ST -> {'EXIT', {Reason, ST}}; + exit:Reason -> {'EXIT', Reason} + end. diff --git a/apps/rebar/test/mock_pkg_resource.erl b/apps/rebar/test/mock_pkg_resource.erl index f609b5f36..2dac11a97 100644 --- a/apps/rebar/test/mock_pkg_resource.erl +++ b/apps/rebar/test/mock_pkg_resource.erl @@ -160,7 +160,7 @@ parse_deps(Deps) -> requirement := Constraint} <- Deps]. to_index(AllDeps, Dict, Repos) -> - catch ets:delete(?PACKAGE_TABLE), + try ets:delete(?PACKAGE_TABLE) catch _:_ -> ok end, rebar_packages:new_package_table(), dict:fold( diff --git a/apps/rebar/test/rebar_compile_SUITE.erl b/apps/rebar/test/rebar_compile_SUITE.erl index 0a9ddfa5a..a67217d30 100644 --- a/apps/rebar/test/rebar_compile_SUITE.erl +++ b/apps/rebar/test/rebar_compile_SUITE.erl @@ -253,7 +253,7 @@ maybe_init_config(Config) -> end. end_per_testcase(_, _Config) -> - catch meck:unload(). + try meck:unload() catch _:_ -> ok end. %% test cases @@ -1546,8 +1546,9 @@ umbrella_mib_first_test(Config) -> PrivMibsDir = filename:join([AppsDir, "_build", "default", "lib", Name, "priv", "mibs"]), FailureRebarConfig = [{mib_first_files, ["mibs/AIMPORTER-MIB.mib"]}], - catch ( - rebar_test_utils:run_and_check(Config, FailureRebarConfig, ["compile"], {ok, [{app, Name}]}) ), + try + rebar_test_utils:run_and_check(Config, FailureRebarConfig, ["compile"], {ok, [{app, Name}]}) + catch _:_ -> ok end, %% check that the bin file was NOT created false = filelib:is_file(filename:join([PrivMibsDir, "AIMPORTER-MIB.bin"])), diff --git a/apps/rebar/test/rebar_ct_SUITE.erl b/apps/rebar/test/rebar_ct_SUITE.erl index 1ac2e9ab4..43a91ff2a 100644 --- a/apps/rebar/test/rebar_ct_SUITE.erl +++ b/apps/rebar/test/rebar_ct_SUITE.erl @@ -1303,7 +1303,8 @@ cfg_cover_spec(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), - RebarConfig = [{ct_opts, [Opt = {cover, "spec/foo.spec"}]}], + Opt = {cover, "spec/foo.spec"}, + RebarConfig = [{ct_opts, [Opt]}], {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return), diff --git a/apps/rebar/test/rebar_hooks_SUITE.erl b/apps/rebar/test/rebar_hooks_SUITE.erl index 68bacc174..4e5cba275 100644 --- a/apps/rebar/test/rebar_hooks_SUITE.erl +++ b/apps/rebar/test/rebar_hooks_SUITE.erl @@ -19,7 +19,7 @@ init_per_testcase(_, Config) -> rebar_test_utils:init_rebar_state(Config). end_per_testcase(_, _Config) -> - catch meck:unload(). + try meck:unload() catch _:_ -> ok end. all() -> [build_and_clean_app, run_hooks_once, run_hooks_once_profiles, diff --git a/apps/rebar/test/rebar_paths_SUITE.erl b/apps/rebar/test/rebar_paths_SUITE.erl index 67d92739c..aed0317ce 100644 --- a/apps/rebar/test/rebar_paths_SUITE.erl +++ b/apps/rebar/test/rebar_paths_SUITE.erl @@ -219,10 +219,10 @@ check_modules(Config) -> ct:pal("code:get_path() -> ~p", [code:get_path()]), ?assertEqual(RootDir ++ "_build/default/plugins/lib/rp_a/ebin", rp_a:f()), - ct:pal("~p", [catch file:list_dir(RootDir ++ "_build/default/lib/")]), - ct:pal("~p", [catch file:list_dir(RootDir ++ "_build/default/lib/rp_b/")]), - ct:pal("~p", [catch file:list_dir(RootDir ++ "_build/default/lib/rp_b/ebin")]), - ct:pal("~p", [catch b:module_info()]), + ct:pal("~p", [safe_list_dir(RootDir ++ "_build/default/lib/")]), + ct:pal("~p", [safe_list_dir(RootDir ++ "_build/default/lib/rp_b/")]), + ct:pal("~p", [safe_list_dir(RootDir ++ "_build/default/lib/rp_b/ebin")]), + ct:pal("~p", [safe_module_info(b)]), ?assertEqual(RootDir ++ "_build/default/lib/rp_b/ebin", rp_b:f()), ?assertEqual(RootDir ++ "_build/default/lib/rp_c/ebin", rp_c:f()), ?assertEqual(RootDir ++ "_build/default/lib/rp_d/ebin", rp_d:f()), @@ -293,4 +293,14 @@ apps_to_str([]) -> "stdlib, kernel"; apps_to_str(Apps) -> AppsStr = unicode:characters_to_list(lists:join(", ", Apps)), - "stdlib, kernel, " ++ AppsStr. \ No newline at end of file + "stdlib, kernel, " ++ AppsStr. + +safe_list_dir(Path) -> + try file:list_dir(Path) + catch Class:Reason -> {Path, {Class, Reason}} + end. + +safe_module_info(Mod) -> + try Mod:module_info() + catch Class:Reason -> {Mod, {Class, Reason}} + end. diff --git a/apps/rebar/test/rebar_pkg_SUITE.erl b/apps/rebar/test/rebar_pkg_SUITE.erl index 6a74fcb96..78cfe5900 100644 --- a/apps/rebar/test/rebar_pkg_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_SUITE.erl @@ -290,7 +290,7 @@ mock_config(Name, Config) -> filelib:ensure_dir(filename:join([CacheDir, "registry"])), ok = ets:tab2file(Tid, filename:join([CacheDir, "registry"])), - catch ets:delete(?PACKAGE_TABLE), + try ets:delete(?PACKAGE_TABLE) catch _:_ -> ok end, rebar_packages:new_package_table(), lists:foreach(fun({{N, Vsn}, [Deps, InnerChecksum, OuterChecksum, _]}) -> case ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(N), Vsn, <<"hexpm">>}) of @@ -365,7 +365,7 @@ mock_config(Name, Config) -> unmock_config(Config) -> meck:unload(), - catch ets:delete(?config(mock_table, Config)). + try ets:delete(?config(mock_table, Config)) catch _:_ -> ok end. copy_to_cache({Pkg,Vsn}, Config) -> Name = <>, diff --git a/apps/rebar/test/rebar_pkg_alias_SUITE.erl b/apps/rebar/test/rebar_pkg_alias_SUITE.erl index 6aaea9c6f..bfdcbb8af 100644 --- a/apps/rebar/test/rebar_pkg_alias_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_alias_SUITE.erl @@ -223,7 +223,7 @@ mock_config(Name, Config) -> meck:new(rebar_prv_update, [passthrough]), meck:expect(rebar_prv_update, do, fun(State) -> {ok, State} end), - catch ets:delete(?PACKAGE_TABLE), + try ets:delete(?PACKAGE_TABLE) catch _:_ -> ok end, rebar_packages:new_package_table(), lists:foreach(fun({{N, Vsn}, [Deps, Checksum, _]}) -> diff --git a/apps/rebar/test/rebar_pkg_repos_SUITE.erl b/apps/rebar/test/rebar_pkg_repos_SUITE.erl index 4cb5ee26a..eb2036d64 100644 --- a/apps/rebar/test/rebar_pkg_repos_SUITE.erl +++ b/apps/rebar/test/rebar_pkg_repos_SUITE.erl @@ -483,7 +483,7 @@ or_in_prerelease(Config) -> %% setup_deps_and_repos(Deps, Repos) -> - catch ets:delete(?PACKAGE_TABLE), + try ets:delete(?PACKAGE_TABLE) catch _:_ -> ok end, true = rebar_packages:new_package_table(), insert_deps(Deps), State = rebar_state:new([{hex, [{repos, [#{name => R} || R <- Repos]}]}]), diff --git a/apps/rebar/test/rebar_plugins_SUITE.erl b/apps/rebar/test/rebar_plugins_SUITE.erl index e0ba3866b..407869711 100644 --- a/apps/rebar/test/rebar_plugins_SUITE.erl +++ b/apps/rebar/test/rebar_plugins_SUITE.erl @@ -40,7 +40,7 @@ init_per_testcase(_, Config) -> rebar_test_utils:init_rebar_state(Config). end_per_testcase(_, _Config) -> - catch meck:unload(). + try meck:unload() catch _:_ -> ok end. all() -> [compile_plugins, compile_global_plugins, complex_plugins, list, upgrade, upgrade_project_plugin, @@ -212,7 +212,7 @@ upgrade(Config) -> {ok, [{app, Name, valid}, {file, PluginBeam}, {plugin, PkgName, <<"0.1.1">>}]} ), - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, mock_pkg_resource:mock([ {pkgdeps, [{{iolist_to_binary(PkgName), <<"0.1.0">>}, []}, {{iolist_to_binary(PkgName), <<"0.0.1">>}, []}, @@ -256,7 +256,7 @@ upgrade_project_plugin(Config) -> {ok, [{app, Name}, {plugin, PkgName, <<"0.1.1">>}]} ), - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, mock_pkg_resource:mock([ {pkgdeps, [{{iolist_to_binary(PkgName), <<"0.1.0">>}, []}, {{iolist_to_binary(PkgName), <<"0.0.1">>}, []}, diff --git a/apps/rebar/test/rebar_upgrade_SUITE.erl b/apps/rebar/test/rebar_upgrade_SUITE.erl index 2eee8e9af..b09124cb2 100644 --- a/apps/rebar/test/rebar_upgrade_SUITE.erl +++ b/apps/rebar/test/rebar_upgrade_SUITE.erl @@ -44,11 +44,11 @@ init_per_testcase(novsn_pkg, Config0) -> [{rebarconfig, RebarConf}, {mock, fun() -> - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, mock_pkg_resource:mock([{pkgdeps, Deps}, {upgrade, []}]) end}, {mock_update, fun() -> - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, mock_pkg_resource:mock([{pkgdeps, UpDeps++Deps}, {upgrade, Upgrades}]) end}, {expected, {ok, [{dep, "fakeapp", "1.1.0"}, {lock, "fakeapp", "1.1.0"}]}} @@ -528,20 +528,20 @@ upgrades(tree_migration) -> %% running the upgrade code is enough to properly upgrade things. mock_deps(git, Deps, Upgrades) -> - catch mock_git_resource:unmock(), + try mock_git_resource:unmock() catch _:_ -> ok end, {SrcDeps, _} = rebar_test_utils:flat_deps(Deps), mock_git_resource:mock([{deps, SrcDeps}, {upgrade, Upgrades}]); mock_deps(pkg, Deps, Upgrades) -> - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, {_, PkgDeps} = rebar_test_utils:flat_deps(Deps), mock_pkg_resource:mock([{pkgdeps, PkgDeps}, {upgrade, Upgrades}]). mock_deps(git, OldDeps, Deps, Upgrades) -> - catch mock_git_resource:unmock(), + try mock_git_resource:unmock() catch _:_ -> ok end, {SrcDeps, _} = rebar_test_utils:flat_deps(Deps++OldDeps), mock_git_resource:mock([{deps, SrcDeps}, {upgrade, Upgrades}]); mock_deps(pkg, OldDeps, Deps, Upgrades) -> - catch mock_pkg_resource:unmock(), + try mock_pkg_resource:unmock() catch _:_ -> ok end, {_, PkgDeps} = rebar_test_utils:flat_deps(Deps++OldDeps), mock_pkg_resource:mock([{pkgdeps, PkgDeps}, {upgrade, Upgrades}]). diff --git a/apps/rebar/test/rebar_utils_SUITE.erl b/apps/rebar/test/rebar_utils_SUITE.erl index 1d20db30f..fb985a7ca 100644 --- a/apps/rebar/test/rebar_utils_SUITE.erl +++ b/apps/rebar/test/rebar_utils_SUITE.erl @@ -44,7 +44,7 @@ init_per_testcase(_, Config) -> rebar_test_utils:init_rebar_state(Config). end_per_testcase(_, _Config) -> - catch meck:unload(). + try meck:unload() catch _:_ -> ok end. all() -> [{group, args_to_tasks}, diff --git a/bootstrap b/bootstrap index 25b935631..9c484a092 100755 --- a/bootstrap +++ b/bootstrap @@ -177,7 +177,7 @@ compile_yrl_file(File) -> {ok, _} = yecc:file(File). compile_erl_file(File, Opts) -> - case compile:file(File, [nowarn_deprecated_catch | Opts]) of + case compile:file(File, Opts) of {ok, _Mod} -> ok; {ok, _Mod, []} -> diff --git a/rebar.config b/rebar.config index 16645f71c..6d189be8f 100644 --- a/rebar.config +++ b/rebar.config @@ -5,8 +5,6 @@ {project_app_dirs, ["apps/*","lib/*",".","vendor/*"]}. {project_plugin_dirs, ["plugins/*","vendor_plugins/*"]}. -{erl_opts, [nowarn_deprecated_catch]}. - %% Duplicated from apps/rebar3: %% - we want people who rely on rebar3 as a dependency to still be able %% to fetch it with git_subdir and have it work @@ -20,7 +18,7 @@ {escript_incl_priv, [{relx, "templates/*"}, {rebar, "templates/*"}]}. -{overrides, [{override, erlware_commons, [{erl_opts, [nowarn_deprecated_catch]}]}, +{overrides, [{add, meck, [{erl_opts, [nowarn_deprecated_catch]}]}, {add, relx, [{erl_opts, [{d, 'RLX_LOG', rebar_log}]}]}]}. {profiles, [ diff --git a/vendor/erlware_commons/src/ec_date.erl b/vendor/erlware_commons/src/ec_date.erl index 747b24646..45971cf8b 100644 --- a/vendor/erlware_commons/src/ec_date.erl +++ b/vendor/erlware_commons/src/ec_date.erl @@ -104,7 +104,7 @@ do_parse(Date, Now, Opts) -> case filter_hints(parse(tokenise(string:uppercase(Date), []), Now, Opts)) of {error, bad_date} -> erlang:throw({?MODULE, {bad_date, Date}}); - {D1, T1} = {{Y, M, D}, {H, M1, S}} + {D1 = {Y, M, D}, T1 = {H, M1, S}} when is_number(Y), is_number(M), is_number(D), is_number(H), is_number(M1), is_number(S) -> @@ -112,7 +112,7 @@ do_parse(Date, Now, Opts) -> true -> {D1, T1}; false -> erlang:throw({?MODULE, {bad_date, Date}}) end; - {D1, _T1, {Ms}} = {{Y, M, D}, {H, M1, S}, {Ms}} + {D1 = {Y, M, D}, {H, M1, S}, {Ms}} when is_number(Y), is_number(M), is_number(D), is_number(H), is_number(M1), is_number(S), diff --git a/vendor/erlware_commons/src/ec_talk.erl b/vendor/erlware_commons/src/ec_talk.erl index 8c3a105fd..888a27d0f 100644 --- a/vendor/erlware_commons/src/ec_talk.erl +++ b/vendor/erlware_commons/src/ec_talk.erl @@ -182,11 +182,8 @@ get_boolean(_) -> get_integer([]) -> no_data; get_integer(String) -> - case (catch list_to_integer(String)) of - {'Exit', _} -> - no_clue; - Integer -> - Integer + try list_to_integer(String) + catch _:_ -> no_clue end. %% @doc Solely returns a string give the string. This is so the same diff --git a/vendor/relx/src/rlx_util.erl b/vendor/relx/src/rlx_util.erl index 349aa7bee..cfff31fc2 100644 --- a/vendor/relx/src/rlx_util.erl +++ b/vendor/relx/src/rlx_util.erl @@ -164,11 +164,12 @@ is_error(_) -> render(Template, Data) when is_list(Template) -> render(rlx_util:to_binary(Template), Data); render(Template, Data) when is_binary(Template) -> - case catch bbmustache:render(Template, Data, - [{key_type, atom}, - {escape_fun, fun(X) -> X end}]) of + try bbmustache:render(Template, Data, + [{key_type, atom}, + {escape_fun, fun(X) -> X end}]) of Bin when is_binary(Bin) -> {ok, Bin}; _ -> {error, render_failed} + catch _:_ -> {error, render_failed} end. load_file(Files, escript, Name) ->