[erlang-questions] gen_statem badrecord,trans_opts

Raimo Niskanen raimo+erlang-questions@REDACTED
Wed May 16 08:52:15 CEST 2018


On Tue, May 15, 2018 at 10:59:50PM +0200, Torben Hoffmann wrote:
> Hi,
> Would it be possible to add some text to the gen_statem docs that this
> message usually means you have messed up one of the actions?
> It wasn't obvious to me before I googled it and then it was a matter of
> chasing down all my actions.
> Somehow I find the error messages of gen_statem harder to work with than
> gen_fsm, which is a pity since gen_statem is so much easier to work with in
> terms of design flexibility and easy to raed code.
> 
> Cheers,
> Torben

The message in this case:
  Context:    child_terminated Reason:
    {{badrecord,trans_opts},
     [{gen_statem,loop_event_actions_list,10,
       [{file,"gen_statem.erl"},{line,1210}]},
      {proc_lib,init_p_do_apply,3,
       [{file,"proc_lib.erl"},{line,247}]}]}

I classify this as a bug, but not severe enough to merit a patch on the 20.3
release.  What the code was trying to do but crashed instead was to
terminate with error:{bad_action_from_state_function,Action} in a regular
Error Report.

The intention is that gen_statem should pinpoint bad actions fairly
precisely.  That crash is fixed in 20.0-rc1 and later so it will terminate
as intended.

I agree that the OP:s crash is not a good error message for end users, but
it was a good one for me since it was precise for me to fix the crash.

Do you have any suggestions about improving correct error messages from
gen_statem, or can you exemplify some that you find hard to understand?
In comparison with gen_fsm, if you like.

Best Regards
/ Raimo


> 
> 
> On Tue, May 15, 2018 at 8:23 AM getonga <getonga@REDACTED> wrote:
> 
> > Thanks, I recheck my source code, and I found the error reason. Thanks for
> > your time.
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> -- 
> https://www.linkedin.com/in/torbenhoffmann/

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions


-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list