mirror of https://github.com/M66B/FairEmail.git
Improved error handling
This commit is contained in:
parent
2bebb4729d
commit
9538804ba0
|
@ -447,13 +447,13 @@ public class FragmentAccount extends FragmentEx {
|
||||||
int auth_type = args.getInt("auth_type");
|
int auth_type = args.getInt("auth_type");
|
||||||
|
|
||||||
if (TextUtils.isEmpty(host))
|
if (TextUtils.isEmpty(host))
|
||||||
throw new Throwable(context.getString(R.string.title_no_host));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_host));
|
||||||
if (TextUtils.isEmpty(port))
|
if (TextUtils.isEmpty(port))
|
||||||
port = (starttls ? "143" : "993");
|
port = (starttls ? "143" : "993");
|
||||||
if (TextUtils.isEmpty(user))
|
if (TextUtils.isEmpty(user))
|
||||||
throw new Throwable(context.getString(R.string.title_no_user));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_user));
|
||||||
if (TextUtils.isEmpty(password) && !insecure)
|
if (TextUtils.isEmpty(password) && !insecure)
|
||||||
throw new Throwable(context.getString(R.string.title_no_password));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
||||||
|
|
||||||
CheckResult result = new CheckResult();
|
CheckResult result = new CheckResult();
|
||||||
result.folders = new ArrayList<>();
|
result.folders = new ArrayList<>();
|
||||||
|
@ -550,6 +550,9 @@ public class FragmentAccount extends FragmentEx {
|
||||||
grpFolders.setVisibility(View.GONE);
|
grpFolders.setVisibility(View.GONE);
|
||||||
btnSave.setVisibility(View.GONE);
|
btnSave.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (ex instanceof IllegalArgumentException)
|
||||||
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||||
.setMessage(Helper.formatThrowable(ex))
|
.setMessage(Helper.formatThrowable(ex))
|
||||||
.setPositiveButton(android.R.string.cancel, null)
|
.setPositiveButton(android.R.string.cancel, null)
|
||||||
|
@ -645,17 +648,17 @@ public class FragmentAccount extends FragmentEx {
|
||||||
EntityFolder junk = (EntityFolder) args.getSerializable("junk");
|
EntityFolder junk = (EntityFolder) args.getSerializable("junk");
|
||||||
|
|
||||||
if (TextUtils.isEmpty(host))
|
if (TextUtils.isEmpty(host))
|
||||||
throw new Throwable(context.getString(R.string.title_no_host));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_host));
|
||||||
if (TextUtils.isEmpty(port))
|
if (TextUtils.isEmpty(port))
|
||||||
port = (starttls ? "143" : "993");
|
port = (starttls ? "143" : "993");
|
||||||
if (TextUtils.isEmpty(user))
|
if (TextUtils.isEmpty(user))
|
||||||
throw new Throwable(context.getString(R.string.title_no_user));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_user));
|
||||||
if (synchronize && TextUtils.isEmpty(password) && !insecure)
|
if (synchronize && TextUtils.isEmpty(password) && !insecure)
|
||||||
throw new Throwable(context.getString(R.string.title_no_password));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
||||||
if (TextUtils.isEmpty(interval))
|
if (TextUtils.isEmpty(interval))
|
||||||
interval = "19";
|
interval = "19";
|
||||||
if (synchronize && drafts == null)
|
if (synchronize && drafts == null)
|
||||||
throw new Throwable(context.getString(R.string.title_no_drafts));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_drafts));
|
||||||
|
|
||||||
if (Color.TRANSPARENT == color)
|
if (Color.TRANSPARENT == color)
|
||||||
color = null;
|
color = null;
|
||||||
|
@ -837,6 +840,9 @@ public class FragmentAccount extends FragmentEx {
|
||||||
btnSave.setEnabled(true);
|
btnSave.setEnabled(true);
|
||||||
pbSave.setVisibility(View.GONE);
|
pbSave.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (ex instanceof IllegalArgumentException)
|
||||||
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||||
.setMessage(Helper.formatThrowable(ex))
|
.setMessage(Helper.formatThrowable(ex))
|
||||||
.setPositiveButton(android.R.string.cancel, null)
|
.setPositiveButton(android.R.string.cancel, null)
|
||||||
|
|
|
@ -600,6 +600,9 @@ public class FragmentIdentity extends FragmentEx {
|
||||||
btnSave.setEnabled(true);
|
btnSave.setEnabled(true);
|
||||||
pbSave.setVisibility(View.GONE);
|
pbSave.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (ex instanceof IllegalArgumentException)
|
||||||
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||||
.setMessage(Helper.formatThrowable(ex))
|
.setMessage(Helper.formatThrowable(ex))
|
||||||
.setPositiveButton(android.R.string.cancel, null)
|
.setPositiveButton(android.R.string.cancel, null)
|
||||||
|
|
Loading…
Reference in New Issue