summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-06-13 15:16:55 -0400
committerGitHub <noreply@github.com>2017-06-13 15:16:55 -0400
commit21a121fa669efb1463ad9160375e715557d83749 (patch)
tree16908378472fc97530593b0e6b63bc4807b2a5ea /src
parent9b1aa9191027647eb370eb6b0d5fa9cbfacc21d4 (diff)
parent7f1301f635b8c07fd22ffdf1c9dcf6f5cbba8655 (diff)
Merge pull request #1572 from ferd/fix-xref-undef-behaviour
Prevent xref crashes with undef behaviours
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_xref.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl
index 51154b5..e6a074f 100644
--- a/src/rebar_prv_xref.erl
+++ b/src/rebar_prv_xref.erl
@@ -168,8 +168,15 @@ keyall(Key, List) ->
lists:flatmap(fun({K, L}) when Key =:= K -> L; (_) -> [] end, List).
get_behaviour_callbacks(exports_not_used, Attributes) ->
- [B:behaviour_info(callbacks) || B <- keyall(behaviour, Attributes) ++
- keyall(behavior, Attributes)];
+ lists:map(fun(Mod) ->
+ try
+ Mod:behaviour_info(callbacks)
+ catch
+ error:undef ->
+ ?WARN("Behaviour ~p is used but cannot be found.", [Mod]),
+ []
+ end
+ end, keyall(behaviour, Attributes) ++ keyall(behavior, Attributes));
get_behaviour_callbacks(_XrefCheck, _Attributes) ->
[].