Class EquinixServiceException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EquinixAuthenticationException, EquinixAuthorizationException, EquinixConflictException, EquinixNotFoundException, EquinixRateLimitException, EquinixServerException

public class EquinixServiceException extends BaseException
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 StatusException Class
401 UnauthorizedEquinixAuthenticationException
403 ForbiddenEquinixAuthorizationException
404 Not FoundEquinixNotFoundException
409 ConflictEquinixConflictException
429 Too Many RequestsEquinixRateLimitException
5xx Server ErrorEquinixServerException

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 Details

    • EquinixServiceException

      public EquinixServiceException(String errorMessage)
      Creates an exception carrying only a message (no HTTP metadata).
      Parameters:
      errorMessage - a human-readable message
    • EquinixServiceException

      public EquinixServiceException(String errorMessage, Exception cause)
      Creates an exception carrying a message and a cause (no HTTP metadata).
      Parameters:
      errorMessage - a human-readable message
      cause - the underlying cause
    • 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 be null.
      exceptionDetails - structured error details parsed from the response body; may be null.
    • EquinixServiceException

      public EquinixServiceException(String errorMessage, Integer statusCode, String path, Map<String,String> httpHeaders, List<ExceptionDetail> exceptionDetails, String correlationId)
      Full constructor used by ResponseErrorMapper when 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 JSON null elements (e.g. a [null] body) and header maps can carry null values - neither may abort exception construction with a NullPointerException.
      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 be null.
      exceptionDetails - structured error details parsed from the response body; may be null.
      correlationId - the SDK-generated X-Correlation-Id of the failed request; may be null.
    • 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 be null.
      exceptionDetails - structured error details parsed from the response body; may be null.
      correlationId - the SDK-generated X-Correlation-Id of the failed request; may be null.
      responseBodySnippet - truncated raw body when no details could be parsed; may be null.
  • Method Details

    • getMessage

      public String 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 parsed ExceptionDetail: 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:
      getMessage in class Throwable
      Returns:
      the full multi-line message