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

Lutz Behnke lutz.behnke@REDACTED
Wed Sep 19 13:08:27 CEST 2018


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

-- 
Lutz Behnke
Hochschule für Angewandte Wissenschaften Hamburg,
Labor für Allgemeine Informatik,

phone: +49 40 42875-8156    mailto:lutz.behnke@REDACTED
fax  : +49 40 2803770       http://users.informatik.haw-hamburg.de/~sage
Berliner Tor 7, 20099 Hamburg, Germany




More information about the erlang-questions mailing list