handle typical network exceptions in AsyncTasks

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@343 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-11-03 23:40:59 +00:00
parent 45465a87ee
commit 114f8db546
5 changed files with 12 additions and 53 deletions

View file

@ -19,7 +19,6 @@ package de.schildbach.pte;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -178,10 +177,6 @@ public abstract class AbstractHafasProvider implements NetworkProvider
{
throw new RuntimeException(x);
}
catch (final SocketTimeoutException x)
{
throw new RuntimeException(x);
}
finally
{
if (is != null)
@ -254,6 +249,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
InputStream is = null;
try
{
is = ParserUtils.scrapeInputStream(apiUri, wrap(request));
@ -479,10 +475,6 @@ public abstract class AbstractHafasProvider implements NetworkProvider
{
throw new RuntimeException(x);
}
catch (final SocketTimeoutException x)
{
throw new RuntimeException(x);
}
catch (final ParseException x)
{
throw new RuntimeException(x);
@ -770,9 +762,9 @@ public abstract class AbstractHafasProvider implements NetworkProvider
}
if (maxStations == 0 || maxStations >= stations.size())
return new NearbyStationsResult(uri, stations);
return new NearbyStationsResult(stations);
else
return new NearbyStationsResult(uri, stations.subList(0, maxStations));
return new NearbyStationsResult(stations.subList(0, maxStations));
}
protected static final Pattern P_NORMALIZE_LINE = Pattern.compile("([A-Za-zÄÖÜäöüßáàâéèêíìîóòôúùû/-]+)[\\s-]*(.*)");