Code example for HttpResponseException

0
	// Interface to AsyncHttpRequest 
	void sendResponseMessage(HttpResponse response) {
 
		StatusLine status = response.getStatusLine();
		if (status.getStatusCode() >= 300) {
			sendFailureMessage(new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()));
		} else { 
			try { 
				HttpEntity entity = null;
				HttpEntity temp = response.getEntity();
				if (temp != null) {
					entity = new BufferedHttpEntity(temp);
				} 
 
				sendSuccessMessage(EntityUtils.toString(entity));
			} catch (IOException e) {
				sendFailureMessage(e);
			} 
		} 
	} 
}