Class ResponseErrorMapper

java.lang.Object
com.eqixiac.equinix.core.http.ResponseErrorMapper

public final class ResponseErrorMapper extends Object
Maps an Equinix API error response (status code + headers + body) into the appropriate typed EquinixServiceException. Centralizes the status-to-subclass selection and the response-body parsing ladder that was previously inlined in EquinixHttpClient, producing a fully-constructed, immutable exception.

The body is parsed by ErrorBodyParser, which recognises the error format of every Equinix service (Fabric / Network Edge / EIA / Resource Manager arrays, IAM {"error":{...}}, STS {"error","error_description"}, Customer Portal and Smart Hands {"errors":[...]}, IBX SmartView v1 and v2, the API gateway object and Apigee faults) and never throws. The first parsed detail is appended to the summary message, so Throwable.getMessage() leads with the service's code, message and field. A body that yields no details (an HTML gateway page, for example) is kept as a truncated snippet on the exception.

Author:
ianjones
  • Method Details

    • toException

      public static EquinixServiceException toException(int statusCode, String path, Map<String,String> httpHeaders, String errorBody, String correlationId)
      Builds the typed exception for an error response.
      Parameters:
      statusCode - the HTTP status code.
      path - the request URI that produced the error.
      httpHeaders - relevant response headers (e.g. Retry-After); may be null.
      errorBody - the raw response body, or null/blank when none was returned.
      correlationId - the SDK-generated X-Correlation-Id sent with the failed request; may be null.
      Returns:
      the typed EquinixServiceException for the status code.