mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-12 08:18:50 +00:00
Hafas: Log error codes to debug.
This commit is contained in:
parent
52207db349
commit
aa028228c0
1 changed files with 80 additions and 68 deletions
|
@ -52,6 +52,8 @@ import javax.annotation.Nullable;
|
|||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
@ -117,6 +119,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
private boolean stationBoardHasLocation = false;
|
||||
private boolean stationBoardCanDoEquivs = true;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractHafasProvider.class);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class Context implements QueryTripsContext
|
||||
{
|
||||
|
@ -1178,6 +1182,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
final String err = svcRes.getString("err");
|
||||
if (!"OK".equals(err))
|
||||
{
|
||||
log.debug("Hafas error: {}", err);
|
||||
if ("H890".equals(err)) // No connections found.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
if ("H891".equals(err)) // No route found (try entering an intermediate station).
|
||||
|
@ -1623,6 +1628,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
if (XmlPullUtil.test(pp, "Err"))
|
||||
{
|
||||
final String code = XmlPullUtil.attr(pp, "code");
|
||||
log.debug("Hafas error: {}", code);
|
||||
if (code.equals("K9260")) // Unknown departure station
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
|
||||
if (code.equals("K9280")) // Unknown intermediate station
|
||||
|
@ -2728,7 +2734,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
return result;
|
||||
}
|
||||
else if (errorCode == 1)
|
||||
else
|
||||
{
|
||||
log.debug("Hafas error: {}", errorCode);
|
||||
if (errorCode == 1)
|
||||
throw new SessionExpiredException();
|
||||
else if (errorCode == 2)
|
||||
// F2: Your search results could not be stored internally.
|
||||
|
@ -2748,7 +2757,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
else if (errorCode == 890)
|
||||
// H890: No connections have been found that correspond to your request. It is possible that the
|
||||
// requested service does not operate from or to the places you stated on the requested date of travel.
|
||||
// requested service does not operate from or to the places you stated on the requested date of
|
||||
// travel.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
else if (errorCode == 891)
|
||||
// H891: Unfortunately there was no route found. Missing timetable data could be the reason.
|
||||
|
@ -2766,7 +2776,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
// H9220: Nearby to the given address stations could not be found.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNRESOLVABLE_ADDRESS);
|
||||
else if (errorCode == 9240)
|
||||
// H9240: Unfortunately there was no route found. Perhaps your start or destination is not served at all
|
||||
// H9240: Unfortunately there was no route found. Perhaps your start or destination is not served at
|
||||
// all
|
||||
// or with the selected means of transport on the required date/time.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
else if (errorCode == 9260)
|
||||
|
@ -2793,6 +2804,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
else
|
||||
throw new IllegalStateException("error " + errorCode + " on " + uri);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
@ -3212,12 +3224,12 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
return new NearbyLocationsResult(null, locations);
|
||||
}
|
||||
else if (error == 2)
|
||||
{
|
||||
return new NearbyLocationsResult(null, NearbyLocationsResult.Status.SERVICE_DOWN);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("Hafas error: {}", error);
|
||||
if (error == 2)
|
||||
return new NearbyLocationsResult(null, NearbyLocationsResult.Status.SERVICE_DOWN);
|
||||
else
|
||||
throw new RuntimeException("unknown error: " + error);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue