Skip to content

Commit 54b4fb1

Browse files
committed
Abort on errors
Fixes several instances where the task would try to complete after encountering an error. Improves output when errors do occur by printing an informative message under noral opperation, and only print the full stacktrace when DEBUG=1 is used. When displayed stacktraces are formatted better by starting them on a new line. Signed-off-by: Winford <[email protected]>
1 parent a5f13f3 commit 54b4fb1

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/atomvm_dialyzer_provider.erl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ do(State) ->
8282
{ok, State}
8383
catch
8484
C:E:S ->
85-
rebar_api:error(
86-
"An error occurred in the ~p task. Class=~p Error=~p Stacktrace=~p~n", [
87-
?PROVIDER, C, E, S
88-
]
89-
),
85+
rebar_api:error("An error occurred in the ~p task.", [?PROVIDER]),
86+
rebar_api:debug("Class=~p Error=~p~nSTACKTRACE:~n~p~n", [C, E, S]),
9087
{error, E}
9188
end.
9289

@@ -150,7 +147,7 @@ do_dialize(Config, State) ->
150147
print_warnings(Problems)
151148
catch
152149
throw:{dialyzer_error, Reason} ->
153-
rebar_api:error("Dialyzer failed! reason: ~p.~n", [Reason])
150+
rebar_api:abort("Dialyzer failed! reason: ~p.~n", [Reason])
154151
end,
155152
ok.
156153

@@ -166,10 +163,10 @@ check_base_plt(Config) ->
166163
[] ->
167164
ok;
168165
_ ->
169-
do_build_base_plt(Config)
166+
ok = do_build_base_plt(Config)
170167
catch
171168
throw:{dialyzer_error, _} ->
172-
do_build_base_plt(Config)
169+
ok = do_build_base_plt(Config)
173170
end,
174171
ok.
175172

@@ -178,7 +175,7 @@ base_plt_absname(Config) ->
178175
Home =
179176
case os:getenv("HOME") of
180177
false ->
181-
rebar_api:error("Unable to locate users home directory");
178+
rebar_api:abort("Unable to locate users home directory");
182179
Path ->
183180
string:trim(Path)
184181
end,
@@ -203,12 +200,13 @@ do_build_base_plt(Config) ->
203200
ok;
204201
Failure ->
205202
print_warnings(Failure),
206-
rebar_api:error("Failed to create project plt!~n")
203+
rebar_api:abort("Failed to create project plt!~n"),
204+
{error, dialyzer_error}
207205
catch
208206
throw:{dialyzer_error, Error} ->
209-
rebar_api:error("Failed to crete plt, error:~p~n", [Error])
210-
end,
211-
ok.
207+
rebar_api:abort("Failed to crete plt, error:~p~n", [Error]),
208+
{error, dialyzer_error}
209+
end.
212210

213211
% @private
214212
check_app_plt(Config, State) ->
@@ -219,7 +217,7 @@ check_app_plt(Config, State) ->
219217
ok
220218
catch
221219
throw:{dialyzer_error, _} ->
222-
do_build_plt(Config, State)
220+
ok = do_build_plt(Config, State)
223221
end,
224222
ok.
225223

@@ -243,12 +241,14 @@ do_build_plt(Config, State) ->
243241
ok;
244242
Failure ->
245243
print_warnings(Failure),
246-
rebar_api:error("Failed to create project plt!~n")
244+
rebar_api:abort("Failed to create project plt!~n"),
245+
{error, dialyzer_error}
246+
247247
catch
248248
throw:{dialyzer_error, Error} ->
249-
rebar_api:error("Failed to crete plt, error:~p~n", [Error])
250-
end,
251-
ok.
249+
rebar_api:abort("Failed to crete plt, error:~p~n", [Error]),
250+
{error, dialyzer_error}
251+
end.
252252

253253
%% @private
254254
plt_absolute_name(State) ->
@@ -281,7 +281,7 @@ atomvm_install_path() ->
281281
BinPath =
282282
case os:find_executable("atomvm") of
283283
false ->
284-
rebar_api:error("Path to AtomVM installation not found!");
284+
rebar_api:abort("Path to AtomVM installation not found!");
285285
AtomVM ->
286286
AtomVM
287287
end,
@@ -310,7 +310,7 @@ get_base_beam_path_list(Base) ->
310310
rebar_api:debug("AtomVM libraries to add to plt: ~p~n", [Libs]),
311311
case Libs of
312312
[] ->
313-
rebar_api:error("Unable to locate AtomVM beams in path"),
313+
rebar_api:abort("Unable to locate AtomVM beams in path"),
314314
{error, no_beams_found};
315315
Ebins ->
316316
Ebins
@@ -335,7 +335,7 @@ app_profile_abs_dir(State) ->
335335
Prof1 when is_atom(Prof1) ->
336336
Prof1;
337337
Arg ->
338-
rebar_api:error("Unable to determine rebar3 profile, got badarg ~p", [Arg]),
338+
rebar_api:abort("Unable to determine rebar3 profile, got badarg ~p", [Arg]),
339339
{error, bad_rebar_profile}
340340
end,
341341
WorkDir = filename:absname(filename:join("_build", Profile)),

0 commit comments

Comments
 (0)