Better handling of json parse errors
If there is a problem parsing the custom from address:
1) Don't do a LogUtils.wtf, as it will crash the app during development
2) Don't toss the main "from" address
Bug: 6318780
Change-Id: Icc3d3259c7b423df960fa7473176cf186f476f59
diff --git a/src/com/android/mail/compose/FromAddressSpinner.java b/src/com/android/mail/compose/FromAddressSpinner.java
index 8b91c1a..97aa73c 100644
--- a/src/com/android/mail/compose/FromAddressSpinner.java
+++ b/src/com/android/mail/compose/FromAddressSpinner.java
@@ -99,7 +99,7 @@
try {
mReplyFromAccounts.addAll(getAccountSpecificFroms(account));
} catch (JSONException e) {
- LogUtils.wtf(LOG_TAG, "Failed parsing from addresses associated with account %s",
+ LogUtils.e(LOG_TAG, e, "Failed parsing from addresses associated with account %s",
account.name);
}
}
@@ -118,14 +118,19 @@
froms.add(replyFrom);
}
if (!TextUtils.isEmpty(account.accountFromAddresses)) {
- JSONArray accounts = new JSONArray(account.accountFromAddresses);
- JSONObject accountString;
- for (int i = 0; i < accounts.length(); i++) {
- accountString = (JSONObject) accounts.get(i);
- ReplyFromAccount a = ReplyFromAccount.deserialize(account, accountString);
- if (a != null) {
- froms.add(a);
+ try {
+ JSONArray accounts = new JSONArray(account.accountFromAddresses);
+ JSONObject accountString;
+ for (int i = 0; i < accounts.length(); i++) {
+ accountString = (JSONObject) accounts.get(i);
+ ReplyFromAccount a = ReplyFromAccount.deserialize(account, accountString);
+ if (a != null) {
+ froms.add(a);
+ }
}
+ } catch (JSONException e) {
+ LogUtils.e(LOG_TAG, e, "Failed to parse accountFromAddresses for account %s",
+ account.name);
}
}
return froms;