[erlang-questions] Return of problematic values in gen_* functions error tuples

Dmitry Klionsky dm.klionsky@REDACTED
Wed Sep 19 13:45:36 CEST 2018


 >> Why are the offending values not returned as part of the tuple when 
signaling an error in virtually all of the stdlib function?

The values might be huge.



On 09/19/2018 02:08 PM, Lutz Behnke wrote:
> Hi there,
>
> I have question I have been wondering about for some time, but which 
> is bugging me right now:
>
>     Why are the offending values not returned as part of the tuple
>         when signaling an error in virtually all of the stdlib function?
>
> Example: The gen_statem:parse_event_result/8 will terminate the state 
> machine with {bad_return_from_state_function,badargs}, but not include 
> the offending value.
> IMO it would help a lot in determining the cause of the fault.
> This is similar in a wide range of functions in all the gen_* modules 
> as well as ets functions. I think I remember some other cases 
> throughout the stdlib, but don't have any ready examples.
> Sometimes the functions just throw a fault with {error, badargs}.
>
> Why not include the bad argument?
>  e.g. {bad_return_from_state_function, {badargs, TheBadTerm}}
>   from gen_statem:parse_event_result/8
> or
>  ets:lookup/3 could return {bardarg, Key}
>
>
> I know that it will break the API to a certain extend, but will 
> patches to change this be considered for inclusion in the mainly 
> sources? I have looked at the gen_statem code and am considering a 
> fork to help me debug.
>
> mfg lutz
>

-- 
BR,
Dmitry




More information about the erlang-questions mailing list