コード例 #1
0
 private void validateResponse(InternalApiResponse response) throws ApiException {
   if (response.getStatusCode() >= 500) {
     // Internal server error
     throw new ApiException("Internal server error returned by API.");
   }
   switch (response.getStatusCode()) {
     case HttpStatus.SC_BAD_REQUEST:
     case HttpStatus.SC_UNPROCESSABLE_ENTITY:
     case HttpStatus.SC_FORBIDDEN:
     case HttpStatus.SC_UNAUTHORIZED:
       throw new ApiDetailedException(response);
     case HttpStatus.SC_NOT_FOUND:
       throw new ApiNotFoundException(response);
     case 429: // Too many requests
       throw new ApiException("Too many requests");
   }
 }