mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 00:08:49 +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.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
@ -117,6 +119,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
private boolean stationBoardHasLocation = false;
|
private boolean stationBoardHasLocation = false;
|
||||||
private boolean stationBoardCanDoEquivs = true;
|
private boolean stationBoardCanDoEquivs = true;
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AbstractHafasProvider.class);
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private static class Context implements QueryTripsContext
|
private static class Context implements QueryTripsContext
|
||||||
{
|
{
|
||||||
|
@ -1178,6 +1182,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
final String err = svcRes.getString("err");
|
final String err = svcRes.getString("err");
|
||||||
if (!"OK".equals(err))
|
if (!"OK".equals(err))
|
||||||
{
|
{
|
||||||
|
log.debug("Hafas error: {}", err);
|
||||||
if ("H890".equals(err)) // No connections found.
|
if ("H890".equals(err)) // No connections found.
|
||||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||||
if ("H891".equals(err)) // No route found (try entering an intermediate station).
|
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"))
|
if (XmlPullUtil.test(pp, "Err"))
|
||||||
{
|
{
|
||||||
final String code = XmlPullUtil.attr(pp, "code");
|
final String code = XmlPullUtil.attr(pp, "code");
|
||||||
|
log.debug("Hafas error: {}", code);
|
||||||
if (code.equals("K9260")) // Unknown departure station
|
if (code.equals("K9260")) // Unknown departure station
|
||||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
|
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
|
||||||
if (code.equals("K9280")) // Unknown intermediate station
|
if (code.equals("K9280")) // Unknown intermediate station
|
||||||
|
@ -2728,7 +2734,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (errorCode == 1)
|
else
|
||||||
|
{
|
||||||
|
log.debug("Hafas error: {}", errorCode);
|
||||||
|
if (errorCode == 1)
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
else if (errorCode == 2)
|
else if (errorCode == 2)
|
||||||
// F2: Your search results could not be stored internally.
|
// 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);
|
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||||
else if (errorCode == 890)
|
else if (errorCode == 890)
|
||||||
// H890: No connections have been found that correspond to your request. It is possible that the
|
// 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);
|
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||||
else if (errorCode == 891)
|
else if (errorCode == 891)
|
||||||
// H891: Unfortunately there was no route found. Missing timetable data could be the reason.
|
// 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.
|
// H9220: Nearby to the given address stations could not be found.
|
||||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNRESOLVABLE_ADDRESS);
|
return new QueryTripsResult(header, QueryTripsResult.Status.UNRESOLVABLE_ADDRESS);
|
||||||
else if (errorCode == 9240)
|
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.
|
// or with the selected means of transport on the required date/time.
|
||||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||||
else if (errorCode == 9260)
|
else if (errorCode == 9260)
|
||||||
|
@ -2793,6 +2804,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
else
|
else
|
||||||
throw new IllegalStateException("error " + errorCode + " on " + uri);
|
throw new IllegalStateException("error " + errorCode + " on " + uri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (is != null)
|
if (is != null)
|
||||||
|
@ -3212,12 +3224,12 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
return new NearbyLocationsResult(null, locations);
|
return new NearbyLocationsResult(null, locations);
|
||||||
}
|
}
|
||||||
else if (error == 2)
|
|
||||||
{
|
|
||||||
return new NearbyLocationsResult(null, NearbyLocationsResult.Status.SERVICE_DOWN);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
log.debug("Hafas error: {}", error);
|
||||||
|
if (error == 2)
|
||||||
|
return new NearbyLocationsResult(null, NearbyLocationsResult.Status.SERVICE_DOWN);
|
||||||
|
else
|
||||||
throw new RuntimeException("unknown error: " + error);
|
throw new RuntimeException("unknown error: " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue