Keyserver exception translateable
This commit is contained in:
@@ -265,7 +265,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
throw new QueryFailedException("Keyserver '" + mHost + "' not found. Error 404");
|
||||
} else {
|
||||
// NOTE: some keyserver do not provide a more detailed error response
|
||||
throw new QueryFailedException("Either no keys or too many have been found. Please improve your query!");
|
||||
throw new QueryTooShortOrTooManyResponsesException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ public abstract class Keyserver {
|
||||
private static final long serialVersionUID = 2703768928624654514L;
|
||||
}
|
||||
|
||||
/**
|
||||
* query too short _or_ too many responses
|
||||
*/
|
||||
public static class QueryTooShortOrTooManyResponsesException extends QueryNeedsRepairException {
|
||||
private static final long serialVersionUID = 2703768928624654514L;
|
||||
}
|
||||
|
||||
public static class AddKeyException extends Exception {
|
||||
private static final long serialVersionUID = -507574859137295530L;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class OperationResults {
|
||||
if (this.isOkBoth()) {
|
||||
str = activity.getResources().getQuantityString(
|
||||
R.plurals.import_keys_added_and_updated_1, mNewKeys, mNewKeys);
|
||||
str += activity.getResources().getQuantityString(
|
||||
str += " "+ activity.getResources().getQuantityString(
|
||||
R.plurals.import_keys_added_and_updated_2, mUpdatedKeys, mUpdatedKeys, withWarnings);
|
||||
} else if (isOkUpdated()) {
|
||||
str = activity.getResources().getQuantityString(
|
||||
|
||||
@@ -307,9 +307,11 @@ public class ImportKeysListFragment extends ListFragment implements
|
||||
if (error == null) {
|
||||
// No error
|
||||
} else if (error instanceof Keyserver.QueryTooShortException) {
|
||||
Notify.showNotify(getActivity(), R.string.error_keyserver_insufficient_query, Notify.Style.ERROR);
|
||||
Notify.showNotify(getActivity(), R.string.error_query_too_short, Notify.Style.ERROR);
|
||||
} else if (error instanceof Keyserver.TooManyResponsesException) {
|
||||
Notify.showNotify(getActivity(), R.string.error_keyserver_too_many_responses, Notify.Style.ERROR);
|
||||
Notify.showNotify(getActivity(), R.string.error_too_many_responses, Notify.Style.ERROR);
|
||||
} else if (error instanceof Keyserver.QueryTooShortOrTooManyResponsesException) {
|
||||
Notify.showNotify(getActivity(), R.string.error_too_short_or_too_many_responses, Notify.Style.ERROR);
|
||||
} else if (error instanceof Keyserver.QueryFailedException) {
|
||||
Log.d(Constants.TAG,
|
||||
"Unrecoverable keyserver query error: " + error.getLocalizedMessage());
|
||||
|
||||
Reference in New Issue
Block a user