Friendly unsubscribe error message

master
M66B 2 weeks ago
parent 3847814aad
commit 7f242cd674

@ -108,12 +108,10 @@ public class FragmentDialogUnsubscribe extends FragmentDialogBase {
connection.getOutputStream().write(request.getBytes());
int status = connection.getResponseCode();
if (status >= 400) {
String error = "Error " + status + ": " + connection.getResponseMessage();
if (status >= 300) {
String error = status + ": " + connection.getResponseMessage();
Log.i("Unsubscribe error=" + error);
InputStream stream = connection.getErrorStream();
String detail = (stream == null || status == 404 ? null : Helper.readStream(stream));
throw new IOException(error + " " + detail);
throw new IllegalArgumentException(error);
} else
Log.i("Unsubscribe status=" + status);
@ -132,7 +130,12 @@ public class FragmentDialogUnsubscribe extends FragmentDialogBase {
@Override
protected void onException(Bundle args, Throwable ex) {
dialog.dismiss();
Log.unexpectedError(getParentFragmentManager(), ex);
if (ex instanceof IllegalArgumentException)
ToastEx.makeText(context,
context.getString(R.string.title_unsubscribe_error, ex.getMessage()),
Toast.LENGTH_LONG).show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentDialogUnsubscribe.this, args, "unsubscribe");
}

@ -1639,6 +1639,7 @@
<string name="title_keywords_btn">Keywords</string>
<string name="title_labels_btn">Labels (Gmail only)</string>
<string name="title_unsubscribe">Unsubscribe</string>
<string name="title_unsubscribe_error">The unsubscribe link in the message does not work. Error %1$s</string>
<string name="title_message_rule">Create rule</string>
<string name="title_no_junk">Not spam</string>
<string name="title_edit_subject">Edit subject &#8230;</string>

Loading…
Cancel
Save