From a127662212fc79017303036cc13a59e784adadbf Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 7 Mar 2019 07:54:36 +0200 Subject: [PATCH] http error handling in legacy parsing code --- .../ktnx/mobileledger/async/RetrieveTransactionsTask.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index c1e51442..88b36c8b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -107,7 +107,7 @@ public class RetrieveTransactionsTask context.onRetrieveDone(null); } private String retrieveTransactionListLegacy(MobileLedgerProfile profile) - throws IOException, ParseException { + throws IOException, ParseException, HTTPException { Progress progress = new Progress(); int maxTransactionId = Progress.INDETERMINATE; ArrayList accountList = new ArrayList<>(); @@ -118,6 +118,12 @@ public class RetrieveTransactionsTask HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal"); http.setAllowUserInteraction(false); publishProgress(progress); + switch (http.getResponseCode()) { + case 200: + break; + default: + throw new HTTPException(http.getResponseCode(), http.getResponseMessage()); + } try (SQLiteDatabase db = MLDB.getWritableDatabase()) { try (InputStream resp = http.getInputStream()) { if (http.getResponseCode() != 200) -- 2.39.5