anchor.diff:          {ok, NewState} ->
               {noreply, NewState, ?PROTO_CONNECTION_TIMEOUT};
           {error, _Reason} ->
  -            {stop, connection_attempt_failed, State}
  +            {stop, termination_reason(connection_attempt_failed, State), State}
       end;
   
   handle_info({Ok, Socket, Data}, #state{status = upgrading_protocol, socket = Socket, ok = Ok} = State) ->
  
positive.code:         {error, _Reason} ->
              % Concrete errors were already logged in 'handle_handshake' so
              % terminate gracefully as to not spam more error logs
              {stop, connection_attempt_failed, State}
      catch Type:Reason ->
          ?error_stacktrace("Unexpected error while performing handshake: ~p:~p", [
              Type, Reason
          ]),
          {stop, connection_attempt_failed, State}
      end;
  
  handle_info({Ok, Socket, Data}, #state{status = ready, socket = Socket, ok = Ok} = State) ->
  
negative.code:         {error, _Reason} ->
              % Concrete errors were already logged in 'handle_protocol_upgrade_response'
              % so terminate gracefully as to not spam more error logs
              {stop, termination_reason(connection_attempt_failed, State), State}
      catch Type:Reason ->
          ?error_stacktrace("Unexpected error during protocol upgrade: ~p:~p", [
              Type, Reason
          ]),
          {stop, termination_reason(connection_attempt_failed, State), State}
      end;
  
  handle_info({Ok, Socket, Data}, #state{status = performing_handshake, socket = Socket, ok = Ok} = State) ->
  