Expected exceptions

This commit is contained in:
M66B 2021-01-04 17:53:07 +01:00
parent 6c00f0e922
commit 522af0c756
1 changed files with 15 additions and 12 deletions

View File

@ -686,11 +686,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException ||
ex instanceof FileNotFoundException)
ToastEx.makeText(ActivitySetup.this, ex.getMessage(), Toast.LENGTH_LONG).show();
else
Log.unexpectedError(getSupportFragmentManager(), ex);
boolean expected =
(ex instanceof IllegalArgumentException ||
ex instanceof FileNotFoundException ||
ex instanceof SecurityException);
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
}
}.execute(this, args, "setup:export");
}
@ -1073,12 +1073,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
ToastEx.makeText(ActivitySetup.this, R.string.title_setup_password_invalid, Toast.LENGTH_LONG).show();
else if (ex instanceof IOException && ex.getCause() instanceof IllegalBlockSizeException)
ToastEx.makeText(ActivitySetup.this, R.string.title_setup_import_invalid, Toast.LENGTH_LONG).show();
else if (ex instanceof IllegalArgumentException ||
ex instanceof FileNotFoundException ||
ex instanceof JSONException)
ToastEx.makeText(ActivitySetup.this, ex.getMessage(), Toast.LENGTH_LONG).show();
else
Log.unexpectedError(getSupportFragmentManager(), ex);
else {
boolean expected =
(ex instanceof IllegalArgumentException ||
ex instanceof FileNotFoundException ||
ex instanceof JSONException ||
ex instanceof SecurityException);
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
}
}
}.execute(this, args, "setup:import");
}
@ -1145,7 +1147,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getSupportFragmentManager(), ex, false);
boolean expected = (ex instanceof SecurityException);
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
}
}.execute(this, args, "setup:cert");
}