From eda5a98448ec0db825f1a60aa53031417c85888e Mon Sep 17 00:00:00 2001 From: steckbrief Date: Mon, 28 Mar 2016 23:15:24 +0200 Subject: Implements FS#176: error logging for httpupload improved --- .../thedevstack/conversationsplus/http/HttpUploadConnection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main') 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(); } -- cgit v1.2.3