Class ResponseErrorMapper
java.lang.Object
com.eqixiac.equinix.core.http.ResponseErrorMapper
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 Summary
Modifier and TypeMethodDescriptionstatic EquinixServiceExceptiontoException(int statusCode, String path, Map<String, String> httpHeaders, String errorBody, String correlationId) Builds the typed exception for an error response.
-
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 benull.errorBody- the raw response body, ornull/blank when none was returned.correlationId- the SDK-generatedX-Correlation-Idsent with the failed request; may benull.- Returns:
- the typed
EquinixServiceExceptionfor the status code.
-