Class EquinixServiceException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.eqixiac.equinix.core.exception.BaseException
com.eqixiac.equinix.core.exception.EquinixServiceException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EquinixAuthenticationException, EquinixAuthorizationException, EquinixConflictException, EquinixNotFoundException, EquinixRateLimitException, EquinixServerException
Thrown when the Equinix API returns an error HTTP response.
This is the base class for all API error exceptions. It carries the HTTP status code,
response headers, request path, and structured error details from the API response body.
It is a sibling of EquinixClientException - both extend BaseException -
so catching EquinixClientException (client/SDK/network errors) does not also catch
API errors, and vice versa. Catch BaseException to handle either.
Specific HTTP status codes are mapped to typed subclasses:
| HTTP Status | Exception Class |
|---|---|
| 401 Unauthorized | EquinixAuthenticationException |
| 403 Forbidden | EquinixAuthorizationException |
| 404 Not Found | EquinixNotFoundException |
| 409 Conflict | EquinixConflictException |
| 429 Too Many Requests | EquinixRateLimitException |
| 5xx Server Error | EquinixServerException |
Error Handling
try {
Connection conn = fabric.connections().getByUuid("uuid");
} catch (EquinixNotFoundException e) {
System.err.println("Not found: " + e.getStatusCode());
} catch (EquinixServiceException e) {
System.err.println("API error: " + e.getMessage());
}
- Author:
- ianjones
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEquinixServiceException(String errorMessage) Creates an exception carrying only a message (no HTTP metadata).EquinixServiceException(String errorMessage, Exception cause) Creates an exception carrying a message and a cause (no HTTP metadata).EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails) Convenience constructor without a correlation id; see the full constructor.EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails, String correlationId) Full constructor used byResponseErrorMapperwhen mapping an HTTP error response into a typed exception.EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails, String correlationId, String responseBodySnippet) Full constructor additionally carrying the raw-body snippet of an error body that could not be parsed into details. -
Method Summary
Modifier and TypeMethodDescriptionThe summary (which for a mapped HTTP error already ends with the first detail's<code>: <message> (field: <property>)line), followed by the HTTP status, URI and correlation id, then one block per parsedExceptionDetail:Error: <code>: <message> (field: <property>)plus any details, developer message, help and property annotations.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
EquinixServiceException
Creates an exception carrying only a message (no HTTP metadata).- Parameters:
errorMessage- a human-readable message
-
EquinixServiceException
-
EquinixServiceException
public EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails) Convenience constructor without a correlation id; see the full constructor.- Parameters:
errorMessage- a human-readable summary message.statusCode- the HTTP status code returned by the API.path- the request URI that produced the error.httpHeaders- relevant response headers (e.g.Retry-After); may benull.exceptionDetails- structured error details parsed from the response body; may benull.
-
EquinixServiceException
public EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails, String correlationId) Full constructor used byResponseErrorMapperwhen mapping an HTTP error response into a typed exception. All API-error metadata is supplied at construction time and stored as immutable copies, so the exception's state cannot change after construction. Null entries are dropped while copying: a gateway can return a details array containing JSONnullelements (e.g. a[null]body) and header maps can carrynullvalues - neither may abort exception construction with aNullPointerException.- Parameters:
errorMessage- a human-readable summary message.statusCode- the HTTP status code returned by the API.path- the request URI that produced the error.httpHeaders- relevant response headers (e.g.Retry-After); may benull.exceptionDetails- structured error details parsed from the response body; may benull.correlationId- the SDK-generatedX-Correlation-Idof the failed request; may benull.
-
EquinixServiceException
public EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String, String> httpHeaders, List<ExceptionDetail> exceptionDetails, String correlationId, String responseBodySnippet) Full constructor additionally carrying the raw-body snippet of an error body that could not be parsed into details.- Parameters:
errorMessage- a human-readable summary message.statusCode- the HTTP status code returned by the API.path- the request URI that produced the error.httpHeaders- relevant response headers (e.g.Retry-After); may benull.exceptionDetails- structured error details parsed from the response body; may benull.correlationId- the SDK-generatedX-Correlation-Idof the failed request; may benull.responseBodySnippet- truncated raw body when no details could be parsed; may benull.
-
-
Method Details
-
getMessage
The summary (which for a mapped HTTP error already ends with the first detail's<code>: <message> (field: <property>)line), followed by the HTTP status, URI and correlation id, then one block per parsedExceptionDetail:Error: <code>: <message> (field: <property>)plus any details, developer message, help and property annotations. When nothing could be parsed, the raw-body snippet is appended instead.- Overrides:
getMessagein classThrowable- Returns:
- the full multi-line message
-