summaryrefslogtreecommitdiff
path: root/app/src/production
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-09-27 16:25:13 +0200
committercyBerta <cyberta@riseup.net>2019-09-27 16:25:13 +0200
commiteebba26668588d5e644441b0dbcc04eb9f9f3eac (patch)
tree9a400d21a6ae0b8c3aa029acf86263d3b94cff3f /app/src/production
parent91877ac8ed64927d14c0762cd4402e5ed736fab9 (diff)
fix error handling for failing fetch of eip-service.json in production flavor and minor refactorings
Diffstat (limited to 'app/src/production')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
index 658e8e15..10582cf3 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
@@ -141,6 +141,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
try {
JSONObject providerJson = new JSONObject(providerDotJsonString);
+
if (provider.define(providerJson)) {
result.putBoolean(BROADCAST_RESULT_KEY, true);
} else {
@@ -148,9 +149,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
}
} catch (JSONException e) {
- String reason_to_fail = pickErrorMessage(providerDotJsonString);
- result.putString(ERRORS, reason_to_fail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
+ setErrorResult(result, providerDotJsonString);
}
return result;
}
@@ -171,13 +170,14 @@ public class ProviderApiManager extends ProviderApiManagerBase {
if (BuildConfig.DEBUG) {
VpnStatus.logDebug("EIP SERVICE JSON: " + eipServiceJsonString);
}
- provider.setEipServiceJson(eipServiceJson);
-
- result.putBoolean(BROADCAST_RESULT_KEY, true);
+ if (eipServiceJson.has(ERRORS)) {
+ setErrorResult(result, eipServiceJsonString);
+ } else {
+ provider.setEipServiceJson(eipServiceJson);
+ result.putBoolean(BROADCAST_RESULT_KEY, true);
+ }
} catch (NullPointerException | JSONException e) {
- String reasonToFail = pickErrorMessage(eipServiceJsonString);
- result.putString(ERRORS, reasonToFail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
+ setErrorResult(result, eipServiceJsonString);
}
return result;
}
@@ -202,9 +202,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
// probably 204
setErrorResult(result, error_io_exception_user_message, null);
} else {
- String reasonToFail = pickErrorMessage(certString);
- result.putString(ERRORS, reasonToFail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
+ setErrorResult(result, certString);
return result;
}
}