tags:

views:

222

answers:

1

I have a module that has the behavior of gen_fsm. Right now I am terminating it by returning the standard {stop, Reason, State} in an appropriate state/message.

It seems to terminate correctly, but it's considered an error during runtime.

Is this normal? Is there a way to stop the fsm process without it being considered an error?

+6  A: 

The return value is {stop,Reason,StateData} not {stop,StateName,StateData}.

An error report is generated if Reason is something other than normal or shutdown. For a normal exit of your server use normal, shutdown is used when the server is asked to exit by its supervisor.

(Edit now that error details have been added.)

gen_fsm is calling client_fsm:terminate(normal, loggedin, {state,#Port<0.144>,12345,"Bob"})

which is leading to a function_clause exception (the function exists but no clause can be matched against those arguments). If you change client_fsm:terminate/3 so that that call succeeds the error should go away.

cthulahoops
Yeah, I meant Reason instead of StateName. Regardless, you answered my question; thanks.
mindeavor.
Sorry, even after I explicitly used the atom normal, it's still producing an error.
mindeavor.
Hmmm... what exactly are you seeing error-wise?
cthulahoops
Ah, I completely see what I did wrong. Though you answered my answer perfectly, my second mistake was still producing an error.I'm going to remove the bits about my second error so that the question at hand is on topic for others to see.
mindeavor.
Really? I'd say they are two errors that a lot of people would hit in sequence. I certainly did testing my initial solution. I think the whole sequence is useful to have here.As a general tip, get used to reading error crash messages - they are cryptic but contain a lot of information.
cthulahoops