diff --git a/rebar.config b/rebar.config index d5acbed..97d6e8e 100644 --- a/rebar.config +++ b/rebar.config @@ -12,7 +12,7 @@ %% == Dependencies and plugins == -{deps, [{elvis_core, "3.2.0"}]}. +{deps, [{elvis_core, "3.2.1"}]}. {project_plugins, [{rebar3_hank, "~> 1.4.0"}, diff --git a/rebar.lock b/rebar.lock index 876145f..87de03c 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,14 +1,14 @@ {"1.2.0", -[{<<"elvis_core">>,{pkg,<<"elvis_core">>,<<"3.2.0">>},0}, +[{<<"elvis_core">>,{pkg,<<"elvis_core">>,<<"3.2.1">>},0}, {<<"katana_code">>,{pkg,<<"katana_code">>,<<"2.1.0">>},1}, {<<"zipper">>,{pkg,<<"zipper">>,<<"1.0.1">>},1}]}. [ {pkg_hash,[ - {<<"elvis_core">>, <<"1B8DD3190903ED7520D03DD53E7535574CFC7354C89FA580BE8FD3F65A70C248">>}, + {<<"elvis_core">>, <<"D5EFDBC55D14521BAB9337FA6822EB41085377BDB1059B2E6794333F40AE4DC1">>}, {<<"katana_code">>, <<"0C42BDCD7E59995876AED9F678CF62E3D12EF42E0FBB2190556E64BFEBDD15C6">>}, {<<"zipper">>, <<"3CCB4F14B97C06B2749B93D8B6C204A1ECB6FAFC6050CACC3B93B9870C05952A">>}]}, {pkg_hash_ext,[ - {<<"elvis_core">>, <<"05EBF8D4840F4A81721907E1DDCE2F3455BE8EA0F0FB280D50C8DE85C40060FA">>}, + {<<"elvis_core">>, <<"4F1996776BB53EF35D0CDA0A6799FC14CDB9190BA89F07883AFCA734D464AE3C">>}, {<<"katana_code">>, <<"AE3BBACA187511588F69695A9FF22251CB2CC672FDCCC180289779BDD25175EF">>}, {<<"zipper">>, <<"6A1FD3E1F0CC1D1DF5642C9A0CE2178036411B0A5C9642851D1DA276BD737C2D">>}]} ]. diff --git a/src/rebar3_lint_prv.erl b/src/rebar3_lint_prv.erl index 208ce91..a140195 100644 --- a/src/rebar3_lint_prv.erl +++ b/src/rebar3_lint_prv.erl @@ -22,23 +22,25 @@ init(State) -> {desc, "A rebar linter plugin based on elvis"}]), {ok, rebar_state:add_provider(State, Provider)}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. +-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, {string(), any()}}. do(State) -> Elvis = get_elvis_config(State), _ = rebar_log:log(info, "elvis analysis starting, this may take a while...", []), try elvis_core:rock(Elvis) of ok -> {ok, State}; - {fail, _} -> - {error, "Linting failed"} + {fail, [{throw, Error} | _]} -> + rebar_api:abort("elvis_core threw an exception: ~p", [Error]); + {fail, Reason} -> + {error, {"Linting failed with ~p", Reason}} catch Error -> rebar_api:abort("elvis_core threw an exception: ~p", [Error]) end. --spec format_error(any()) -> iolist(). -format_error(Reason) -> - io_lib:format("~p", [Reason]). +-spec format_error({string(), any()}) -> iolist(). +format_error({Message, Reason}) -> + io_lib:format(Message, [Reason]). -spec get_elvis_config(rebar_state:t()) -> elvis_config:configs(). get_elvis_config(State) -> diff --git a/test/test_app_SUITE.erl b/test/test_app_SUITE.erl index d55e235..4479f53 100644 --- a/test/test_app_SUITE.erl +++ b/test/test_app_SUITE.erl @@ -19,4 +19,6 @@ test_app(_Config) -> [#{dirs => ["src"], filter => "*.erl", rules => [{elvis_style, max_function_length, #{max_length => 1}}]}]), - {error, "Linting failed"} = rebar3_lint_prv:do(BadState). + {error, {Message = "Linting failed with ~p", Reason}} = rebar3_lint_prv:do(BadState), + % Check that this doesn't throw + io:format("~p", [rebar3_lint_prv:format_error({Message, Reason})]).