diff --git a/src/cre_client.erl b/src/cre_client.erl index 7df8605..3274ccc 100644 --- a/src/cre_client.erl +++ b/src/cre_client.erl @@ -166,18 +166,23 @@ handle_call( _Request, _From, ClientState ) -> handle_cast( {cre_reply, From, A, Delta}, ClientState ) -> #client_state{ reply_map = ReplyMap, - state_map = #{ From := State } } = ClientState, + state_map = StateMap } = ClientState, - case State of - idle -> start_timer( From ); - _ -> ok - end, + ClientState1 = + case StateMap of + #{ From := State } -> + case State of + idle -> start_timer( From ); + _ -> ok + end, - #{ From := ReplyLst } = ReplyMap, + #{ From := ReplyLst } = ReplyMap, - ClientState1 = - ClientState#client_state{ reply_map = ReplyMap#{ From => [{A, Delta}|ReplyLst] }, - state_map = #{ From => primed } }, + ClientState#client_state{ reply_map = ReplyMap#{ From => [{A, Delta}|ReplyLst] }, + state_map = #{ From => primed } }; + + _ -> ClientState + end, {noreply, ClientState1};