Skip to content

Commit 44cf004

Browse files
committed
Handle empty error message when changing account password
Also add same explanatory note as more general error handling section below.
1 parent 7e1de0c commit 44cf004

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,13 @@ public void onAccountChanged(OnAccountChanged event) {
286286
showChangePasswordProgressDialog(false);
287287

288288
if (event.isError()) {
289-
ToastUtils.showToast(getActivity(), event.error.message, ToastUtils.Duration.LONG);
289+
// We usually rely on event.error.type and provide our own localized message.
290+
// This case is exceptional because:
291+
// 1. The server-side error type is generic, but patching this server-side is quite involved
292+
// 2. We know the error string return from the server has decent localization
293+
String errorMessage = !TextUtils.isEmpty(event.error.message) ? event.error.message
294+
: getString(R.string.error_post_account_settings);
295+
ToastUtils.showToast(getActivity(), errorMessage, ToastUtils.Duration.LONG);
290296
AppLog.e(T.SETTINGS, event.error.message);
291297
} else {
292298
ToastUtils.showToast(getActivity(), R.string.change_password_confirmation, ToastUtils.Duration.LONG);

0 commit comments

Comments
 (0)