anchor.diff:          ok ->
               vmq_hook:all(on_register, [Peer, ClientId, undefined, undefined]),
               check_will(F, State#state{clean_session=CleanSession});
  -        {error, _Reason} ->
  +        {error, Reason} ->
  +            lager:error("can't register client ~p due to ~p", [ClientId, Reason]),
               {connection_attempted,
                send_connack(?CONNACK_SERVER, State)}
       end;
  
positive.code:     {connected, send_connack(?CONNACK_ACCEPT, State)};
  check_will(#mqtt_frame_connect{will_topic=""}, State) ->
      %% null topic.... Mosquitto sends a CONNACK_INVALID_ID...
      {connection_attempted,
       send_connack(?CONNACK_INVALID_ID, State)};
  check_will(#mqtt_frame_connect{will_topic=Topic, will_msg=Msg, will_qos=Qos}, State) ->
  
negative.code:                                                          will_topic=LWTopic,
                                                           will_msg=Msg})};
                  false ->
                      lager:error("last will message has invalid size for client ~p", [ClientId]),
                      {connection_attempted,
                       send_connack(?CONNACK_SERVER, State)}
              end;
          _ ->
              lager:error("can't authenticate last will for client ~p", [ClientId]),
              {connection_attempted, send_connack(?CONNACK_AUTH, State)}
      end.
  
  