diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-07-09 13:01:13 +0000 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-07-09 13:04:45 +0000 |
commit | 05e22e4d5c831888450bfc15e88dc2882b837d6c (patch) | |
tree | be79a1103492c1cdb7640ce596d2a73a56873fd9 /src | |
parent | 9affae5c0003d0061114507195bffe2e13062fb9 (diff) |
Fix reporting of error:undef exceptions
The wide-cast catching of undef errors would make it so any provider
calling an undefined function would be reported as a missing 'do' for
the provider.
This patch inspects the stacktrace to know if `Provider:do/1` is indeed
the missing callback, and reports the rest properly.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index b1647f0..f097429 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -128,9 +128,15 @@ do([ProviderName | Rest], State) -> {error, Error} catch error:undef -> - %% This should really only happen if a plugin provider doesn't export do/1 - ?DEBUG("Undefined call to provider's do function:~n~p", [erlang:get_stacktrace()]), - ?PRV_ERROR({bad_provider_namespace, ProviderName}); + Stack = erlang:get_stacktrace(), + case Stack of + [{ProviderName, do, [_], _}|_] -> + %% This should really only happen if a plugin provider doesn't export do/1 + ?DEBUG("Undefined call to provider's do/1 function:~n~p", [Stack]), + ?PRV_ERROR({bad_provider_namespace, ProviderName}); + _ -> % re-raise + erlang:raise(error, undef, Stack) + end; error:{badrecord,provider} -> {error, ProviderName} end. |