Interface CommonResponse

All Known Subinterfaces:
CommunicationMessage, ExternalResponse, Response
All Known Implementing Classes:
AbstractCommunicationMessage, BroadcastUserMessage, EmptyExternalResponseMessage, ExternalMessage, ExternalResponseMessage, ResponseMessage, UserResponseMessage

public interface CommonResponse
Common response contract providing error code and message accessors.

Implemented by all response types in the protocol layer. An error code of 0 indicates success; any non-zero value signals an error condition.

Since:
25.1
Author:
渔民小镇
date:
2025-09-16
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the error code. 0 indicates success; any other value indicates an error.
    Get the human-readable error message.
    default boolean
    Check whether this response represents an error.
    default boolean
    Check whether this response represents a successful outcome.
    default void
    Populate the error code and message from the given ErrorInformation.
    void
    setErrorCode(int errorCode)
    Set the error code. 0 indicates success; any other value indicates an error.
    void
    setErrorMessage(String errorMessage)
    Set the human-readable error message.
  • Method Details

    • getErrorCode

      int getErrorCode()
      Get the error code. 0 indicates success; any other value indicates an error.
      Returns:
      the error code
    • setErrorCode

      void setErrorCode(int errorCode)
      Set the error code. 0 indicates success; any other value indicates an error.
      Parameters:
      errorCode - the error code
    • getErrorMessage

      String getErrorMessage()
      Get the human-readable error message.
      Returns:
      the error message, or null on success
    • setErrorMessage

      void setErrorMessage(String errorMessage)
      Set the human-readable error message.
      Parameters:
      errorMessage - the error message
    • setError

      default void setError(ErrorInformation error)
      Populate the error code and message from the given ErrorInformation.
      Parameters:
      error - the error information source
    • hasError

      default boolean hasError()
      Check whether this response represents an error.
      Returns:
      true if the error code is non-zero
    • isSuccess

      default boolean isSuccess()
      Check whether this response represents a successful outcome.
      Returns:
      true if the error code is 0