private void checkResponseStatus ( HttpResponse response ) throws IOException { int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( statusCode >= 200 && statusCode < 300 ) { return ; } else if ( statusCode == 401 || statusCode == 403 ) { throw new UploadcareAuthenticationException ( streamToString ( response . getEntity ( ) . getContent ( ) ) ) ; } else if ( statusCode == 400 || statusCode == 404 ) { throw new UploadcareInvalidRequestException ( streamToString ( response . getEntity ( ) . getContent ( ) ) ) ; } else { throw new UploadcareApiException ( "Unknown exception during an API call, response:" + streamToString ( response . getEntity ( ) . getContent ( ) ) ) ; } }
Verifies that the response status codes are within acceptable boundaries and throws corresponding exceptions otherwise .