diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-03-28 23:15:24 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-03-28 23:15:24 +0200 |
commit | eda5a98448ec0db825f1a60aa53031417c85888e (patch) | |
tree | 6566f37512e8df841a56d9fc802de4e2987b496a /src/main/java/de/thedevstack | |
parent | 711ab9f2b1b625373a7046774c7b78e59f826589 (diff) |
Implements FS#176: error logging for httpupload improved
Diffstat (limited to 'src/main/java/de/thedevstack')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java index 4cf7e282..f28dee36 100644 --- a/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java +++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpUploadConnection.java @@ -11,6 +11,7 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.Scanner; import javax.net.ssl.HttpsURLConnection; @@ -154,6 +155,7 @@ public class HttpUploadConnection implements Transferable { private void upload() { OutputStream os = null; + InputStream errorStream = null; HttpURLConnection connection = null; PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_upload_"+message.getUuid()); try { @@ -213,13 +215,17 @@ public class HttpUploadConnection implements Transferable { mXmppConnectionService.resendMessage(message, delayed); } } else { + errorStream = connection.getErrorStream(); + Logging.e("httpupload", "file upload failed: http code (" + code + ") " + new Scanner(errorStream).useDelimiter("\\A").next()); fail(); } } catch (IOException e) { - Logging.d(Config.LOGTAG, e.getMessage()); + errorStream = connection.getErrorStream(); + Logging.e("httpupload", "http response: " + new Scanner(errorStream).useDelimiter("\\A").next() + ", exception message: " + e.getMessage()); fail(); } finally { StreamUtil.close(os); + StreamUtil.close(errorStream); if (connection != null) { connection.disconnect(); } |