diff options
author | Tristan Sloughter <[email protected]> | 2014-10-22 21:16:55 -0500 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2014-10-23 11:16:36 -0500 |
commit | 04ea67a7eded3cc296e27ce1a9ae766a638035df (patch) | |
tree | 5f375f981e537a332024f0d60901d9296676a0de /src/relx.erl | |
parent | c3b538199f387a536812fcaf57ccc46de48e88e9 (diff) | |
download | relx-04ea67a7eded3cc296e27ce1a9ae766a638035df.tar.gz relx-04ea67a7eded3cc296e27ce1a9ae766a638035df.tar.bz2 relx-04ea67a7eded3cc296e27ce1a9ae766a638035df.zip |
use providers PRV_ERROR and format_error/2
Diffstat (limited to 'src/relx.erl')
-rw-r--r-- | src/relx.erl | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/relx.erl b/src/relx.erl index 37918be..cf0b367 100644 --- a/src/relx.erl +++ b/src/relx.erl @@ -26,7 +26,7 @@ do/7, do/8, do/9, - format_error/1, + format_error/2, opt_spec_list/0]). -export_type([error/0]). @@ -215,18 +215,18 @@ opt_spec_list() -> {version, undefined, "version", undefined, "Print relx version"}, {root_dir, $r, "root", string, "The project root directory"}]. --spec format_error(Reason::term()) -> string(). -format_error({invalid_return_value, Provider, Value}) -> +-spec format_error(Reason::term(), rlx_state:t()) -> string(). +format_error({invalid_return_value, Provider, Value}, _) -> io_lib:format(lists:flatten([providers:format(Provider), " returned an invalid value ", - io_lib:format("~p", [Value])]), []); -format_error({opt_parse, {invalid_option, Opt}}) -> + io_lib:format("~p", [Value])]), []); +format_error({opt_parse, {invalid_option, Opt}}, _) -> io_lib:format("invalid option ~s~n", [Opt]); -format_error({opt_parse, Arg}) -> +format_error({opt_parse, Arg}, _) -> io_lib:format("~p~n", [Arg]); -format_error({error, {relx, Reason}}) -> - format_error(Reason); -format_error({error, {Module, Reason}}) -> - io_lib:format("~s~n", [Module:format_error(Reason)]). +format_error({error, {relx, Reason}}, State) -> + format_error(Reason, State); +format_error({error, {Module, Reason}}, State) -> + io_lib:format("~s~n", [Module:format_error(Reason, State)]). %%============================================================================ %% internal api @@ -303,13 +303,13 @@ usage() -> report_error(State, Error) -> case Error of {error, {relx, {opt_parse, _}}} -> - io:format(standard_error, format_error(Error), []), + io:format(standard_error, format_error(Error, State), []), usage(); {error, {rlx_cmd_args, _}} -> - io:format(standard_error, format_error(Error), []), + io:format(standard_error, format_error(Error, State), []), usage(); _ -> - io:format(standard_error, format_error(Error), []) + io:format(standard_error, format_error(Error, State), []) end, case rlx_state:caller(State) of command_line -> |