统计下载出错log

This commit is contained in:
huangzhuanghua
2016-10-09 09:49:00 +08:00
parent 8aa90935d8
commit 52f2dd22f2
6 changed files with 74 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package com.gh.download;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.gh.common.util.HttpsUtils;
import com.gh.common.util.Utils;
@ -56,7 +57,7 @@ public class DownloadThread extends Thread {
URL url = new URL(entry.getUrl());
Utils.log("url = " + entry.getUrl());
HttpURLConnection connection = null;
HttpURLConnection connection;
if ("https".equals(url.getProtocol())) {
connection = HttpsUtils.getHttpsURLConnection(url);
} else {
@ -146,11 +147,13 @@ public class DownloadThread extends Thread {
bos.close();
}
} catch (Exception e) {
String errorMsg = Log.getStackTraceString(e);
//e.getMessage() will null error
if (!TextUtils.isEmpty(e.getMessage()) && e.getMessage().contains("connection timeout")) {
listener.onStatusChanged(DownloadStatus.timeout);
listener.onStatusChanged(DownloadStatus.timeout, errorMsg);
} else {
listener.onStatusChanged(DownloadStatus.neterror);
listener.onStatusChanged(DownloadStatus.neterror, errorMsg);
}
Utils.log(DownloadThread.class.getSimpleName(),
"exception-->" + e.toString());