Better error handling when init is present but wrong

This commit is contained in:
Hans Svensson 2019-02-28 09:56:16 +01:00
parent 95bf0d4b6c
commit 6d6fff2612

View File

@ -117,9 +117,12 @@ join_errors(Prefix, Errors, Pfun) ->
check_call(Source, "init" = FunName, Args, Options) ->
PatchFun = fun(T) -> {tuple, [typerep, T]} end,
case check_call(Source, FunName, Args, Options, PatchFun) of
{error, _} when Args == [] ->
Err = {error, _} when Args == [] ->
%% Try with default init-function
check_call(insert_init_function(Source, Options), FunName, Args, Options, PatchFun);
case check_call(insert_init_function(Source, Options), FunName, Args, Options, PatchFun) of
{error, _} -> Err; %% The first error is most likely better...
Res -> Res
end;
Res ->
Res
end;