浏览代码

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.
pull/603/head
Fred Hebert 10 年前
父节点
当前提交
05e22e4d5c
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. +9
    -3
      src/rebar_core.erl

+ 9
- 3
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.

正在加载...
取消
保存