From ec8e35b6583187d0579b9d07c07f53da295f91a3 Mon Sep 17 00:00:00 2001 From: nwuensche Date: Mon, 19 Aug 2019 15:11:26 +0200 Subject: [PATCH] Show nice notification when adding entry without connected server Close #806 --- .../fr/gaulupeau/apps/Poche/service/IntentServiceBase.java | 3 +++ .../main/java/fr/gaulupeau/apps/Poche/service/MainService.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/IntentServiceBase.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/IntentServiceBase.java index 69e101cb5..ab077e347 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/service/IntentServiceBase.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/IntentServiceBase.java @@ -75,6 +75,9 @@ protected ActionResult processException(Exception e, String scope) { } // IOExceptions in most cases mean temporary error, // in some cases may mean that the action was completed anyway. + } else if(e instanceof IllegalArgumentException && !getSettings().isConfigurationOk()) { + result.setErrorType(ActionResult.ErrorType.INCORRECT_CONFIGURATION); + result.setMessage(e.toString()); } else { // other exceptions meant to be handled outside result.setErrorType(ActionResult.ErrorType.UNKNOWN); result.setMessage(e.toString()); diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java index 5ade05888..2fe0df396 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/MainService.java @@ -260,7 +260,7 @@ private Pair syncOfflineQueue(ActionRequest actionRequest) { default: throw new IllegalArgumentException("Unknown action: " + action); } - } catch(IncorrectConfigurationException | UnsuccessfulResponseException | IOException e) { + } catch(IncorrectConfigurationException | UnsuccessfulResponseException | IOException | IllegalArgumentException e) { ActionResult r = processException(e, "syncOfflineQueue()"); if(!r.isSuccess()) itemResult = r; } catch(Exception e) {