diff --git a/enabler/src/de/schildbach/pte/util/ParserUtils.java b/enabler/src/de/schildbach/pte/util/ParserUtils.java index 294f552a..26f85b41 100644 --- a/enabler/src/de/schildbach/pte/util/ParserUtils.java +++ b/enabler/src/de/schildbach/pte/util/ParserUtils.java @@ -170,6 +170,9 @@ public final class ParserUtils if (testExpired(firstChars)) throw new SessionExpiredException(); + if (testInternalError(firstChars)) + throw new InternalErrorException(url, new InputStreamReader(is, requestEncoding)); + if (sessionCookieName != null) { for (final Map.Entry> entry : connection.getHeaderFields().entrySet()) @@ -299,6 +302,18 @@ public final class ParserUtils return false; } + private static final Pattern P_INTERNAL_ERROR = Pattern.compile(">\\s*(Internal error in gateway)\\s*<"); + + public static boolean testInternalError(final String content) + { + // check for internal error + final Matcher m = P_INTERNAL_ERROR.matcher(content); + if (m.find()) + return true; + + return false; + } + private static final Pattern P_HTML_UNORDERED_LIST = Pattern.compile("", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); private static final Pattern P_HTML_LIST_ITEM = Pattern.compile("
  • (.*?)
  • ", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); private static final Pattern P_HTML_BREAKS = Pattern.compile("()+", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); diff --git a/enabler/test/de/schildbach/pte/util/ParserUtilsTest.java b/enabler/test/de/schildbach/pte/util/ParserUtilsTest.java index ad9b43a8..3da1f002 100644 --- a/enabler/test/de/schildbach/pte/util/ParserUtilsTest.java +++ b/enabler/test/de/schildbach/pte/util/ParserUtilsTest.java @@ -99,4 +99,11 @@ public class ParserUtilsTest { assertTrue(ParserUtils.testExpired("

    Ihre Verbindungskennung ist nicht mehr gültig.

    ")); } + + @Test + public void internalError() throws Exception + { + assertTrue(ParserUtils + .testInternalError(" Internal error in gateway

    Internal error in gateway

    ")); + } }