Package org.moera.lib.node.exception
Class MoeraNodeApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.moera.lib.node.exception.MoeraNodeException
org.moera.lib.node.exception.MoeraNodeApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MoeraNodeApiAuthenticationException
,MoeraNodeApiNotFoundException
,MoeraNodeApiOperationException
,MoeraNodeApiValidationException
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionMoeraNodeApiException
(int status, String body) Constructs a newMoeraNodeApiException
with the specified HTTP status code and the response body that may contain additional error details.MoeraNodeApiException
(int status, String errorCode, String errorMessage) Constructs a newMoeraNodeApiException
with the specified status code, error code, and error message.MoeraNodeApiException
(int status, Result result) Constructs a newMoeraNodeApiException
based on the provided status and result.protected
MoeraNodeApiException
(String message) Constructs aMoeraNodeApiException
with the specified detail message. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the specific error code associated with this exception.int
Retrieves the HTTP status code associated with this exception.protected static Result
parseResult
(String body) Parses the given string representation of a JSON response body into aResult
object.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
status
protected int status -
errorCode
-
-
Constructor Details
-
MoeraNodeApiException
Constructs aMoeraNodeApiException
with the specified detail message.- Parameters:
message
- the detail message
-
MoeraNodeApiException
Constructs a newMoeraNodeApiException
with the specified status code, error code, and error message.- Parameters:
status
- the HTTP status codeerrorCode
- the specific error code returned by the API, may benull
errorMessage
- the detailed error message returned by the API, may benull
-
MoeraNodeApiException
Constructs a newMoeraNodeApiException
based on the provided status and result. This constructor allows creating an exception using an HTTP status and aResult
object, which contains an error code and message.- Parameters:
status
- the HTTP status coderesult
- theResult
object containing an error code and message, may benull
-
MoeraNodeApiException
Constructs a newMoeraNodeApiException
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 errorbody
- the response body that may contain aResult
object in serialized format
-
-
Method Details
-
parseResult
Parses the given string representation of a JSON response body into aResult
object.- Parameters:
body
- the response body in JSON format, may benull
- Returns:
- a
Result
object if the parsing succeeds, ornull
if the body isnull
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
Retrieves the specific error code associated with this exception.- Returns:
- the error code, or
null
if no error code is set
-