class AwsServiceHelper {

    public void handleAmazonException(AmazonServiceException amazonServiceException, String message) throws IllegalArgumentException, ObjectNotFoundException
    {
        if (amazonServiceException.getStatusCode() == HttpStatus.SC_BAD_REQUEST)
        {
            throw new IllegalArgumentException(message + " Reason: " + amazonServiceException.getMessage(), amazonServiceException);
        }
        else if (amazonServiceException.getStatusCode() == HttpStatus.SC_NOT_FOUND)
        {
            throw new ObjectNotFoundException(message + " Reason: " + amazonServiceException.getMessage(), amazonServiceException);
        }

        throw amazonServiceException;
    }

}