summaryrefslogtreecommitdiff
path: root/src/rebar3.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-05-10 21:06:41 -0400
committerFred Hebert <mononcqc@ferd.ca>2015-05-10 21:06:41 -0400
commit5d817c4371d3d1a8a64102abdb897a961e4ccda2 (patch)
treefbb4958ef930a3e5f6e65e0f725453012c0e4516 /src/rebar3.erl
parent062bee5985463ef3dcd35af3b0a34b946fd710f5 (diff)
parentfa95321774f930c1d1e294403ee1cdac2d5be428 (diff)
Merge pull request #420 from tsloughter/case_catch
remove uses of 'case catch'
Diffstat (limited to 'src/rebar3.erl')
-rw-r--r--src/rebar3.erl54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 92803c5..1a02407 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -44,33 +44,14 @@
%% escript Entry point
main(Args) ->
- case catch(run(Args)) of
+ try run(Args) of
{ok, _State} ->
erlang:halt(0);
- rebar_abort ->
- erlang:halt(1);
- {error, rebar_abort} ->
- erlang:halt(1);
- {error, {Module, Reason}} ->
- case code:which(Module) of
- non_existing ->
- ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []),
- ?DEBUG("Uncaught error: ~p ~p", [Module, Reason]),
- ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []);
- _ ->
- ?ERROR(Module:format_error(Reason), [])
- end,
- erlang:halt(1);
- {error, Error} when is_list(Error) ->
- ?ERROR(Error, []),
- erlang:halt(1);
Error ->
- %% Nothing should percolate up from rebar_core;
- %% Dump this error to console
- ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []),
- ?DEBUG("Uncaught error: ~p", [Error]),
- ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []),
- erlang:halt(1)
+ handle_error(Error)
+ catch
+ _:Error ->
+ handle_error(Error)
end.
%% Erlang-API entry point
@@ -251,3 +232,28 @@ global_option_spec_list() ->
%{config, $C, "config", string, "Rebar config file to use."},
{task, undefined, undefined, string, "Task to run."}
].
+
+handle_error(rebar_abort) ->
+ erlang:halt(1);
+handle_error({error, rebar_abort}) ->
+ erlang:halt(1);
+handle_error({error, {Module, Reason}}) ->
+ case code:which(Module) of
+ non_existing ->
+ ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []),
+ ?DEBUG("Uncaught error: ~p ~p", [Module, Reason]),
+ ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []);
+ _ ->
+ ?ERROR(Module:format_error(Reason), [])
+ end,
+ erlang:halt(1);
+handle_error({error, Error}) when is_list(Error) ->
+ ?ERROR(Error, []),
+ erlang:halt(1);
+handle_error(Error) ->
+ %% Nothing should percolate up from rebar_core;
+ %% Dump this error to console
+ ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []),
+ ?DEBUG("Uncaught error: ~p", [Error]),
+ ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []),
+ erlang:halt(1).