统计下载出错log
This commit is contained in:
@ -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());
|
||||
|
||||
Reference in New Issue
Block a user