From 9adab9b89d49e7c8706e34b87be7d5123ce181cd Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 13 Jul 2017 13:18:19 +0200 Subject: Be forgiving of non-list values at encode --- lib/diameter/src/base/diameter_gen.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/diameter/src') diff --git a/lib/diameter/src/base/diameter_gen.erl b/lib/diameter/src/base/diameter_gen.erl index 243bc7965a..3d0612c294 100644 --- a/lib/diameter/src/base/diameter_gen.erl +++ b/lib/diameter/src/base/diameter_gen.erl @@ -124,9 +124,12 @@ enc(_, _, {0,_}, [], _, _) -> enc(_, _, _, undefined, _, _) -> []; -enc(_, AvpName, _, T, _, _) - when not is_list(T) -> - ?THROW([repeated_avp_as_non_list, AvpName, T]); +%% Be forgiving when a list of values is expected. If the value itself +%% is a list then the user has to wrap it to avoid each member from +%% being interpreted as an individual AVP value. +enc(Name, AvpName, Arity, V, Opts, Mod) + when not is_list(V) -> + enc(Name, AvpName, Arity, [V], Opts, Mod); enc(Name, AvpName, {Min, Max}, Values, Opts, Mod) -> H = avp_header(AvpName, Mod), -- cgit v1.2.3