if (body.contains("\"error\":")) {
ErrorResponse errorResponse = gson.fromJson(body,
ErrorResponse.class);
ErrorData error = errorResponse.error;
throw new APIError(error.message, error.code);
}
try {
return gson.fromJson(body, responseClass);
} catch (JsonSyntaxException e) {
throw new APIError("Server error. Invalid response format.", 9999);
}
}