private static void ensureStatusOk ( HttpResponse < String > response ) throws ClientErrorException , ServerErrorException , OtherCommunicationException { int responseStatus = response . getStatus ( ) ; if ( isClientError ( responseStatus ) ) { throw new ClientErrorException ( response . getBody ( ) ) ; } else if ( isServerError ( responseStatus ) ) { throw new ServerErrorException ( ) ; } else if ( isOtherErrorResponse ( responseStatus ) ) { throw new OtherCommunicationException ( ) ; } }
~~~~~~~ Error handling ~~~~~~~~~