public static Response failure(SessionId sessionId, Throwable reason) {
    Response response = new Response();
    response.setSessionId(sessionId != null ? sessionId.toString() : null);
    response.setValue(reason);
    response.setStatus(ERROR_CODES.toStatusCode(reason));
    response.setState(ERROR_CODES.toState(response.getStatus()));
    return response;
  }
public static Response failure ( SessionId sessionId , Throwable reason ) { Response response = new Response ( ) ; response . setSessionId ( sessionId != null ? sessionId . toString ( ) : null ) ; response . setValue ( reason ) ; response . setStatus ( ERROR_CODES . toStatusCode ( reason ) ) ; response . setState ( ERROR_CODES . toState ( response . getStatus ( ) ) ) ; return response ; }
Creates a response object for a failed command execution.

@param sessionId ID of the session that executed the command.
@param reason the failure reason.
@return the new response object.