Added support for 'Unknown Host' error message

This commit is contained in:
daniel oeh 2012-09-22 14:02:13 +02:00
parent 7a687583a2
commit bc91c382a0
3 changed files with 9 additions and 0 deletions

View File

@ -71,6 +71,7 @@
<string name="download_error_parser_exception">Parser Exception</string>
<string name="download_error_unsupported_type">Unsupported Feed type</string>
<string name="download_error_connection_error">Connection error</string>
<string name="download_error_unknown_host">Unknown host</string>
<string name="cancel_all_downloads_label">Cancel all downloads</string>
<string name="download_cancelled_msg">Download cancelled</string>
<string name="download_report_title">Downloads completed</string>

View File

@ -11,6 +11,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import android.util.Log;
import de.danoeh.antennapod.AppConfig;
@ -93,6 +94,9 @@ public class HttpDownloader extends Downloader {
} catch (SocketTimeoutException e) {
e.printStackTrace();
onFail(DownloadError.ERROR_CONNECTION_ERROR, e.getMessage());
} catch (UnknownHostException e) {
e.printStackTrace();
onFail(DownloadError.ERROR_UNKNOWN_HOST, e.getMessage());
} catch (IOException e) {
e.printStackTrace();
onFail(DownloadError.ERROR_IO_ERROR, e.getMessage());

View File

@ -15,6 +15,7 @@ public class DownloadError {
public static final int ERROR_DEVICE_NOT_FOUND = 8;
public static final int ERROR_HTTP_DATA_ERROR = 9;
public static final int ERROR_NOT_ENOUGH_SPACE = 10;
public static final int ERROR_UNKNOWN_HOST = 11;
/** Get a human-readable string for a specific error code. */
public static String getErrorString(Context context, int code) {
@ -41,6 +42,9 @@ public class DownloadError {
case ERROR_CONNECTION_ERROR:
resId = R.string.download_error_connection_error;
break;
case ERROR_UNKNOWN_HOST:
resId = R.string.download_error_unknown_host;
break;
default:
resId = R.string.download_error_error_unknown;
}