diff options
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 -> |