aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_check.erl18
-rw-r--r--lib/asn1/test/error_SUITE.erl23
2 files changed, 24 insertions, 17 deletions
diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl
index 208b4eb180..547a5b01f4 100644
--- a/lib/asn1/src/asn1ct_check.erl
+++ b/lib/asn1/src/asn1ct_check.erl
@@ -2068,8 +2068,8 @@ normalize_boolean(_,false,_) ->
false;
normalize_boolean(S,Bool=#'Externalvaluereference'{},CType) ->
get_normalized_value(S,Bool,CType,fun normalize_boolean/3,[]);
-normalize_boolean(_,Other,_) ->
- throw({error,{asn1,{'invalid default value',Other}}}).
+normalize_boolean(S, _, _) ->
+ asn1_error(S, {illegal_value, "BOOLEAN"}).
normalize_integer(_S, Int, _) when is_integer(Int) ->
Int;
@@ -2116,7 +2116,7 @@ normalize_bitstring(S, Value, Type)->
#valuedef{value=Val} ->
normalize_bitstring(S, Val, Type);
_ ->
- asn1_error(S, illegal_bitstring_value)
+ asn1_error(S, {illegal_value, "BIT STRING"})
end;
RecList when is_list(RecList) ->
[normalize_bs_item(S, Item, Type) || Item <- RecList];
@@ -2124,18 +2124,18 @@ normalize_bitstring(S, Value, Type)->
%% Already normalized.
Bs;
_ ->
- asn1_error(S, illegal_bitstring_value)
+ asn1_error(S, {illegal_value, "BIT STRING"})
end.
normalize_bs_item(S, #'Externalvaluereference'{value=Name}, Type) ->
case lists:keymember(Name, 1, Type) of
true -> Name;
- false -> asn1_error(S, illegal_bitstring_value)
+ false -> asn1_error(S, {illegal_value, "BIT STRING"})
end;
normalize_bs_item(_, Atom, _) when is_atom(Atom) ->
Atom;
normalize_bs_item(S, _, _) ->
- asn1_error(S, illegal_bitstring_value).
+ asn1_error(S, {illegal_value, "BIT STRING"}).
hstring_to_binary(L) ->
byte_align(hstring_to_bitstring(L)).
@@ -5840,8 +5840,6 @@ format_error({enum_not_ascending,Id,N,Prev}) ->
format_error({enum_reused_value,Id,Val}) ->
io_lib:format("'~s' has the value '~p' which is used more than once",
[Id,Val]);
-format_error(illegal_bitstring_value) ->
- "expecting a BIT STRING value";
format_error({illegal_class_name,Class}) ->
io_lib:format("the class name '~s' is illegal (it must start with an uppercase letter and only contain uppercase letters, digits, or hyphens)", [Class]);
format_error(illegal_external_value) ->
@@ -5865,7 +5863,9 @@ format_error({illegal_typereference,Name}) ->
format_error(illegal_table_constraint) ->
"table constraints may only be applied to CLASS.&field constructs";
format_error(illegal_value) ->
- "expected a value";
+ "expecting a value";
+format_error({illegal_value, TYPE}) ->
+ io_lib:format("expecting a ~s value", [TYPE]);
format_error({invalid_fields,Fields,Obj}) ->
io_lib:format("invalid ~s in ~p", [format_fields(Fields),Obj]);
format_error({invalid_bit_number,Bit}) ->
diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl
index d41134e5cb..c097943c75 100644
--- a/lib/asn1/test/error_SUITE.erl
+++ b/lib/asn1/test/error_SUITE.erl
@@ -778,6 +778,9 @@ values(Config) ->
" bs5 BIT STRING ::= holder-2.&str\n"
" bs6 BIT STRING ::= holder-2.&obj\n"
+ " b1 BOOLEAN ::= 42\n"
+ " b2 BOOLEAN ::= {a,b}\n"
+
" HOLDER ::= CLASS {\n"
" &str IA5String,\n"
" &obj HOLDER OPTIONAL\n"
@@ -820,20 +823,24 @@ values(Config) ->
{structured_error,{M,18},asn1ct_check,
{undefined_field,'UndefinedField'}},
{structured_error,{M,19},asn1ct_check,
- illegal_bitstring_value},
+ {illegal_value, "BIT STRING"}},
{structured_error,{M,20},asn1ct_check,
- illegal_bitstring_value},
+ {illegal_value, "BIT STRING"}},
{structured_error,{M,21},asn1ct_check,
- illegal_bitstring_value},
+ {illegal_value, "BIT STRING"}},
{structured_error,{M,22},asn1ct_check,
- illegal_bitstring_value},
+ {illegal_value, "BIT STRING"}},
{structured_error,{M,23},asn1ct_check,
- illegal_bitstring_value},
+ {illegal_value, "BIT STRING"}},
{structured_error,{M,24},asn1ct_check,
- illegal_bitstring_value},
- {structured_error,{M,31},asn1ct_check,
+ {illegal_value, "BIT STRING"}},
+ {structured_error,{M,25},asn1ct_check,
+ {illegal_value, "BOOLEAN"}},
+ {structured_error,{M,26},asn1ct_check,
+ {illegal_value, "BOOLEAN"}},
+ {structured_error,{M,33},asn1ct_check,
illegal_external_value},
- {structured_error,{M,32},asn1ct_check,
+ {structured_error,{M,34},asn1ct_check,
illegal_external_value}
]
} = run(P, Config),