aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/src/asn1ct.erl')
-rw-r--r--lib/asn1/src/asn1ct.erl29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index a167d27f82..e26fadd160 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -39,7 +39,7 @@
add_tobe_refed_func/1,add_generated_refed_func/1,
maybe_rename_function/3,latest_sindex/0,current_sindex/0,
set_current_sindex/1,next_sindex/0,maybe_saved_sindex/2,
- parse_and_save/2,verbose/3,warning/3,error/3]).
+ parse_and_save/2,verbose/3,warning/3,warning/4,error/3]).
-include("asn1_records.hrl").
-include_lib("stdlib/include/erl_compile.hrl").
@@ -825,10 +825,13 @@ generate({true,{M,_Module,GenTOrV}},OutFile,EncodingRule,Options) ->
case catch specialized_decode_prepare(EncodingRule,M,GenTOrV,Options) of
{error, enoent} -> ok;
{error, Reason} -> warning("Error in configuration "
- "file: ~n~p~n",[Reason],Options);
+ "file: ~n~p~n",[Reason],Options,
+ "Error in configuration file");
{'EXIT',Reason} -> warning("Internal error when "
"analyzing configuration "
- "file: ~n~p~n",[Reason],Options);
+ "file: ~n~p~n",[Reason],Options,
+ "Internal error when "
+ "analyzing configuration");
_ -> ok
end,
@@ -2524,14 +2527,14 @@ type_check(#'Externaltypereference'{}) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Report functions.
%%
-%% Errors messages are controlled with the 'errors' compiler option
+%% Error messages are controlled with the 'errors' compiler option
%% Warning messages are controlled with the 'warnings' compiler option
%% Verbose messages are controlled with the 'verbose' compiler option
error(Format, Args, S) ->
case is_error(S) of
true ->
- io:format("Error: " ++ Format, Args);
+ io:format(Format, Args);
false ->
ok
end.
@@ -2544,6 +2547,17 @@ warning(Format, Args, S) ->
ok
end.
+warning(Format, Args, S, Reason) ->
+ case {is_werr(S), is_error(S), is_warning(S)} of
+ {true, true, _} ->
+ io:format(Format, Args),
+ throw({error, Reason});
+ {false, _, true} ->
+ io:format(Format, Args);
+ _ ->
+ ok
+ end.
+
verbose(Format, Args, S) ->
case is_verbose(S) of
true ->
@@ -2566,3 +2580,8 @@ is_verbose(S) when is_record(S, state) ->
is_verbose(S#state.options);
is_verbose(O) ->
lists:member(verbose, O).
+
+is_werr(S) when is_record(S, state) ->
+ is_werr(S#state.options);
+is_werr(O) ->
+ lists:member(warnings_as_errors, O).