diff options
author | Parménides GV <parmegv@sdf.org> | 2013-11-07 11:26:44 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2013-12-10 18:16:07 +0100 |
commit | 803134b94029160a5c885a2d93d78080b0aa8013 (patch) | |
tree | 314b49eef4bc652e2b93e9690407ad6cc08217e8 /src/se/leap | |
parent | 8abbfb678433c9033674db2c53070a01aa3a16a0 (diff) |
Cleaner error message.
Diffstat (limited to 'src/se/leap')
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderAPI.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java index 5d049d42..4dc1844a 100644 --- a/src/se/leap/bitmaskclient/ProviderAPI.java +++ b/src/se/leap/bitmaskclient/ProviderAPI.java @@ -464,7 +464,7 @@ public class ProviderAPI extends IntentService { ConfigHelper.saveSharedPref(Provider.CA_CERT, cert_string); result.putBoolean(RESULT_KEY, true); } else { - String reason_to_fail = cert_string; + String reason_to_fail = pickErrorMessage(cert_string); result.putString(ERRORS, reason_to_fail); result.putBoolean(RESULT_KEY, false); } @@ -506,6 +506,10 @@ public class ProviderAPI extends IntentService { result.putBoolean(RESULT_KEY, true); } catch (JSONException e) { + //TODO Error message should be contained in that provider_dot_json_string + String reason_to_fail = pickErrorMessage(provider_dot_json_string); + result.putString(ERRORS, reason_to_fail); + result.putBoolean(RESULT_KEY, false); } return result; } @@ -529,7 +533,7 @@ public class ProviderAPI extends IntentService { result.putBoolean(RESULT_KEY, true); } catch (JSONException e) { - String reason_to_fail = eip_service_json_string; + String reason_to_fail = pickErrorMessage(eip_service_json_string); result.putString(ERRORS, reason_to_fail); result.putBoolean(RESULT_KEY, false); } @@ -540,6 +544,18 @@ public class ProviderAPI extends IntentService { return EIP_SERVICE_JSON_DOWNLOADED; } + private String pickErrorMessage(String string_json_error_message) { + String error_message = ""; + try { + JSONObject json_error_message = new JSONObject(string_json_error_message); + error_message = json_error_message.getString(ERRORS); + } catch (JSONException e) { + // TODO Auto-generated catch block + error_message = string_json_error_message; + } + + return error_message; + } /** * Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider. * |