anchor.diff:      rc([Dict:rec2msg(element(1, Rec))], RC, Dict).
   
   %% failed_avp/3
  +
  +failed_avp(_, [] = No, _) ->
  +    No;
   
   failed_avp(Msg, [_|_] = Avps, Dict) ->
       [failed(Msg, [{'AVP', Avps}], Dict)].
  
positive.code: %% select_error/3
  %%
  %% Extract the first appropriate RC or {RC, #diameter_avp{}}
  %% pair from an errors list.
  %%
  %% RFC 6733:
  %%
  
negative.code: 
  %% reset/4
  %%
  %% Set Result-Code and/or Failed-AVP (maybe). Only RC and {RC, AVP}
  %% are the result of decode. AVP or {RC, [AVP]} can be set in an
  %% answer for encode, as a convenience for injecting additional AVPs
  %% into Failed-AVP; eg. 5001 = DIAMETER_AVP_UNSUPPORTED.
  
  reset(Msg, [], _) ->
      Msg;
  
  reset(Msg, [{RC, As} | Avps], Dict)
    when is_list(As) ->
      reset(Msg, [RC | As ++ Avps], Dict);
  
  reset(Msg, [{RC, Avp} | Avps], Dict) ->
      reset(Msg, [RC, Avp | Avps], Dict);
  
  reset(Msg, [#diameter_avp{} | _] = Avps, Dict) ->
      set(Msg, failed_avp(Msg, Avps, Dict), Dict);
  
  reset(Msg, [RC | Avps], Dict) ->
      set(Msg, rc(Msg, RC, Dict) ++ failed_avp(Msg, Avps, Dict), Dict).
  
  %% set/3
  
  