Class MoeraNodeApiException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MoeraNodeApiAuthenticationException, MoeraNodeApiNotFoundException, MoeraNodeApiOperationException, MoeraNodeApiValidationException

public class MoeraNodeApiException extends MoeraNodeException
Represents an exception thrown when an error occurs while interacting with the Moera Node API. This exception is specifically used for API-related errors, including issues with request validation, missing objects, or failed operations, as indicated by the HTTP status codes.

The exception provides additional context about the error, including the status code and optional error code details.

See Also:
  • Field Details

    • status

      protected int status
    • errorCode

      protected String errorCode
  • Constructor Details

    • MoeraNodeApiException

      protected MoeraNodeApiException(String message)
      Constructs a MoeraNodeApiException with the specified detail message.
      Parameters:
      message - the detail message
    • MoeraNodeApiException

      public MoeraNodeApiException(int status, String errorCode, String errorMessage)
      Constructs a new MoeraNodeApiException with the specified status code, error code, and error message.
      Parameters:
      status - the HTTP status code
      errorCode - the specific error code returned by the API, may be null
      errorMessage - the detailed error message returned by the API, may be null
    • MoeraNodeApiException

      public MoeraNodeApiException(int status, Result result)
      Constructs a new MoeraNodeApiException based on the provided status and result. This constructor allows creating an exception using an HTTP status and a Result object, which contains an error code and message.
      Parameters:
      status - the HTTP status code
      result - the Result object containing an error code and message, may be null
    • MoeraNodeApiException

      public MoeraNodeApiException(int status, String body)
      Constructs a new MoeraNodeApiException with the specified HTTP status code and the response body that may contain additional error details.
      Parameters:
      status - the HTTP status code associated with the error
      body - the response body that may contain a Result object in serialized format
  • Method Details

    • parseResult

      protected static Result parseResult(String body)
      Parses the given string representation of a JSON response body into a Result object.
      Parameters:
      body - the response body in JSON format, may be null
      Returns:
      a Result object if the parsing succeeds, or null if the body is null or an error occurs during deserialization
    • getStatus

      public int getStatus()
      Retrieves the HTTP status code associated with this exception.
      Returns:
      the HTTP status code
    • getErrorCode

      public String getErrorCode()
      Retrieves the specific error code associated with this exception.
      Returns:
      the error code, or null if no error code is set