Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #54 from LogentriesCommunity/handle-response-failures
Browse files Browse the repository at this point in the history
handle response failures
  • Loading branch information
StephenHynes7 authored Sep 5, 2016
2 parents bb2d2ba + e14013a commit b0077c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/main/java/com/logentries/net/LogentriesClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.logentries.net;

import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
Expand All @@ -13,6 +14,8 @@
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

import android.util.Log;

public class LogentriesClient {
// Logentries server endpoints for logs data.
private static final String LE_TOKEN_API = "data.logentries.com"; // For token-based stream input
Expand Down Expand Up @@ -148,7 +151,12 @@ public void write(String data) throws IOException {
} else {
// HTTP input mode.
postRequest.setEntity(new StringEntity(data, "UTF8"));
httpClient.execute(postRequest);
try {
httpClient.execute(postRequest);
} catch (HttpResponseException ex) {
Log.e("LogentriesAndroidLogger", "Received status code:" + ex.getStatusCode());
Log.e("LogentriesAndroidLogger", "Error message:" + ex.getMessage());
}
}
}

Expand Down

0 comments on commit b0077c5

Please sign in to comment.