From 55868eec63d8b60b8ef448cb935dc74d573bc14e Mon Sep 17 00:00:00 2001 From: Robert Kolner Date: Wed, 21 Sep 2011 18:18:26 +0200 Subject: [PATCH] Added exception handling for cases where xml from server is incompatible with the one expected by the application. --- src/com/studentersamfundet/app/FeedFetcher.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/studentersamfundet/app/FeedFetcher.java b/src/com/studentersamfundet/app/FeedFetcher.java index 3b81f8e..2ab6bf1 100644 --- a/src/com/studentersamfundet/app/FeedFetcher.java +++ b/src/com/studentersamfundet/app/FeedFetcher.java @@ -81,7 +81,15 @@ public class FeedFetcher { db = dbf.newDocumentBuilder(); doc = db.parse(in); } catch (ParserConfigurationException e) { - } catch (SAXException e) {} + /* This should never happen. */ + } catch (SAXException e) { + /* This shouldn't happen unless the feed returned by the server + * is somehow incompatible with the what the application expects. + * If it happens, the best course of action is to pretend we failed + * to download the event list (it's close enough and it simplifies + * exception-handling). */ + throw new IOException("Bad response from server."); + } doc.getDocumentElement().normalize();