Skip to content

Commit

Permalink
improve null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantchauhan-appdirect authored and naponce committed Jul 31, 2020
1 parent dffff4d commit 8f4c4c9
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -140,10 +139,10 @@ private APIResult processResponse(Response<MeteredUsageResponse> response) throw
return new APIResult(true, response.body().toString());
}
String errorBodyMessage = null;
if (!Objects.isNull(response.errorBody())) {
if (response.errorBody() != null) {
errorBodyMessage = response.errorBody().string();
}
String errorMessage = !StringUtils.isEmpty(errorBodyMessage) ? response.message().concat(" " + errorBodyMessage) : response.message();
String errorMessage = !StringUtils.isEmpty(errorBodyMessage) ? response.message().concat(" ".concat(errorBodyMessage)) : response.message();
log.error("Metered Usage API Client failed with error={}", errorMessage);
return APIResult.failure(response.code(), String.format("Failed to inform Usage with errorCode=%s, message=%s", response.code(), errorMessage));
}
Expand Down

0 comments on commit 8f4c4c9

Please sign in to comment.