Android HttpResponseException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpResponseException class.

This code example shows how to use the following methods:
	private void makeRequest() throws IOException { 
		HttpResponse response = client.execute(request, context);
 
		StatusLine status = response.getStatusLine();
		if (status.getStatusCode() >= 300) {
			responseHandler.onFailure(protocol, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()));
		} else { 
			byte[] httpResponseByte = EntityUtils.toByteArray(response.getEntity());
			// add to cache 
			ResponseData responseData = new ResponseData(status.getStatusCode(), httpResponseByte);
			try { 
				AsyncCacheClient.getInstance().put(cacheProtocol, cacheId, responseData);
			} catch (NullPointerException e) {
				// no cache 
			} 
			responseHandler.onSuccess(protocol, httpResponseByte);
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:e, getMessage, getStatusCode
            Log.d(TAG, "enter doInBackground()");
            String targetUrl = params[0] + "?tel=" + params[1] + "&devid=" + params[2] + "&simserial=" + params[3];
            try { 
                RestfulClient.post(targetUrl, query, pullParser);
            } catch (HttpResponseException e){
                if(404 == e.getStatusCode()){
                    Log.d(TAG, "this android user is not found. try to regist.");
                    return RESULT_STATE_NOT_REGIST;
                } else { 
                    Log.e(TAG, e.getMessage(), e);
                    return RESULT_STATE_SERVER_ERROR;
                } 
            } catch (Exception e) {
                Log.e(TAG, e.getMessage(), e);
                return RESULT_STATE_CLIENT_ERROR;
            } 
            if(pullParser.resultIsSuccess()){
                return RESULT_STATE_OK;
            } else { 
                return RESULT_STATE_NOT_REGIST;
5
CodeRank
This code example shows how to use the following methods:
        } catch(IOException e) {
            sendFailureMessage(e, null);
        } 
 
        if(status.getStatusCode() >= 300) {
            sendFailureMessage(new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody);
        } else { 
            sendSuccessMessage(responseBody);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage, getStatusCode
				.socketTimeout(timeoutInMS)
				.execute().returnContent().asString(); 
			return Iterables.get(Splitter.on(RESPONSE_SEPARATOR).split(responseBody), 0);
		} 
		catch (HttpResponseException e) {
			if (e.getStatusCode() == HTTP_CODE_NOT_FOUND) {
				throw new ServiceNotFoundException(String.format("Service %s for %s not found",
						serviceSlashProperty, loginAtDomain));
			} 
			else { 
				throw new LocatorClientException(String.format("HTTP error %d: %s", e.getStatusCode(), e.getMessage()), e);
			} 
		} catch (MalformedURLException e) {
			throw new LocatorClientException(e.getMessage(), e);
		} catch (SocketTimeoutException e) {
			throw new LocatorClientException(e.getMessage(), e);
		} catch (IOException e) {
			throw new LocatorClientException(e.getMessage(), e);
		} 
	} 
5
CodeRank
This code example shows how to use the following methods:getMessage, printStackTrace, getStatusCode
			try { 
				request(); 
			}  
			 
			catch (HttpResponseException e) {
				dealWithExcaption(e.getStatusCode(), e.getMessage(), e);
				e.printStackTrace();
			} catch (IllegalStateException e) {
				dealWithExcaption(1, e.getMessage(), e);
				e.printStackTrace();
			}  
			catch (NullPointerException e) {
				dealWithExcaption(1, e.getMessage(), e);
				e.printStackTrace();
			} 
			catch (IOException e) {
				dealWithExcaption(1, e.getMessage(), e);
				e.printStackTrace();
			} 
		} 
5
CodeRank
This code example shows how to use the following methods:
 
    // 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);
            } 
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
        } catch(IOException e) {
            sendFailureMessage(e, (String) null, request_tag);
        } 
 
        if(status.getStatusCode() >= 300) {
            sendFailureMessage(new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody, request_tag);
        } else { 
            sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), responseBody, request_tag);
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
        } catch(IOException e) {
            sendFailureMessage(e, (String) null);
        } 
 
        if(status.getStatusCode() >= 300) {
            sendFailureMessage(new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody);
        } else { 
            sendSuccessMessage(responseBody);
        } 
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:

Related Android HttpResponseException Questions & Answers:

Other Android HttpResponseException Examples

64:				return list;
65:	
66:			} catch (HttpResponseException e) {
67:				Log.e("Error:", e.getMessage());
68:				return null;
-
90:				return place;
91:	
92:			} catch (HttpResponseException e) {
93:				Log.e("Error in Perform Details", e.getMessage());
94:				throw e;

Read More

See Code Examples for Android HttpResponseException Methods: