Closed adolfoportilla closed 5 years ago
Just a quick thought based on the discussion we had earlier, can punt on it for now since it's probably out of scope.
public class ResponseHandler {
public static handleErrorResponse(final Response response) throws IOException {
JsonObject body = gson.fromJson(response.body().string(), JsonObject.class);
String code = "";
JsonElement codeElement = body.get("code");
if (codeElement != null) {
code = codeElement.getAsString();
}
String message = body.get("message").getAsString();
String error = body.get("error").getAsString();
Integer statusCode = response.code();
return new ResponseError(statusCode, error, message, code);
}
}
public class ResponseError {
public ResponseError(int statusCode, String error, String message, int code) {
...
}
}
if (!response.isSuccessful()) {
ResponseError error = ResponseHandler.handleErrorResponse(response);
throw new SmartcarException(error.getMessage(), error.getCode(), ...);
}
Codecov Report
51.67% <4.54%> (+3.22%)
51 <0> (ø)
6.68% <0%> (-10.11%)
5 <0> (-10)
79.62% <ø> (ø)
12 <0> (ø)
79.41% <0%> (ø)
6 <0> (ø)
0% <0%> (-91.67%)
0 <0> (-10)
76.19% <100%> (+0.99%)
11 <0> (ø)
Continue to review full report at Codecov.