diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-08 22:52:21 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-08 22:54:44 +0200 |
commit | 317eeb72e0e4a6855910a7ac26295735ccb77553 (patch) | |
tree | ec9ff2f957d5d75a15c57d72fb9d52a978a39d3b | |
parent | 1cb1ae238a2d497dcd72a544a540e70f401529f2 (diff) |
Fix Dialyzer warning
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/rebar_utils.erl | 18 |
2 files changed, 12 insertions, 7 deletions
@@ -117,7 +117,6 @@ The following discrepancies are known and safe to ignore: ``` rebar_utils.erl:147: Call to missing or unexported function escript:foldl/3 -rebar_utils.erl:180: The created fun has no local return ``` It is **strongly recommended** to check the code with diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index e19911b..4148160 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -105,7 +105,7 @@ sh(Command0, Options0) -> case sh_loop(Port, OutputHandler, []) of {ok, _Output} = Ok -> Ok; - {error, Err} -> + {error, {_Rc, _Output}=Err} -> ErrorHandler(Command, Err) end. @@ -211,9 +211,7 @@ expand_sh_flag(return_on_error) -> end}; expand_sh_flag({abort_on_error, Message}) -> {error_handler, - fun(_Command, _Err) -> - ?ABORT(Message, []) - end}; + log_msg_and_abort(Message)}; expand_sh_flag(abort_on_error) -> {error_handler, fun log_and_abort/2}; @@ -233,9 +231,17 @@ expand_sh_flag({cd, _CdArg} = Cd) -> expand_sh_flag({env, _EnvArg} = Env) -> {port_settings, Env}. --spec log_and_abort(string(), integer()) -> no_return(). +-type err_handler() :: fun((string(), {integer(), string()}) -> no_return()). +-spec log_msg_and_abort(string()) -> err_handler(). +log_msg_and_abort(Message) -> + fun(_Command, {_Rc, _Output}) -> + ?ABORT(Message, []) + end. + +-spec log_and_abort(string(), {integer(), string()}) -> no_return(). log_and_abort(Command, {Rc, Output}) -> - ?ABORT("~s failed with error: ~w and output:~n~s~n", [Command, Rc, Output]). + ?ABORT("~s failed with error: ~w and output:~n~s~n", + [Command, Rc, Output]). sh_loop(Port, Fun, Acc) -> receive |