mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
Add Log.d for QueryFailedException
This commit is contained in:
parent
8a2ffd8f90
commit
dfd5aa65a5
@ -200,12 +200,12 @@ public class HkpKeyserver extends Keyserver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses,
|
||||
InsufficientQuery {
|
||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryException,
|
||||
QueryNeedsRepairException {
|
||||
ArrayList<ImportKeysListEntry> results = new ArrayList<ImportKeysListEntry>();
|
||||
|
||||
if (query.length() < 3) {
|
||||
throw new InsufficientQuery();
|
||||
throw new QueryTooShortException();
|
||||
}
|
||||
|
||||
String encodedQuery;
|
||||
@ -226,9 +226,9 @@ public class HkpKeyserver extends Keyserver {
|
||||
if (e.getData().toLowerCase(Locale.US).contains("no keys found")) {
|
||||
return results;
|
||||
} else if (e.getData().toLowerCase(Locale.US).contains("too many")) {
|
||||
throw new TooManyResponses();
|
||||
throw new TooManyResponsesException();
|
||||
} else if (e.getData().toLowerCase(Locale.US).contains("insufficient")) {
|
||||
throw new InsufficientQuery();
|
||||
throw new QueryTooShortException();
|
||||
}
|
||||
}
|
||||
throw new QueryException("querying server(s) for '" + mHost + "' failed");
|
||||
|
@ -34,8 +34,8 @@ public class KeybaseKeyserver extends Keyserver {
|
||||
private String mQuery;
|
||||
|
||||
@Override
|
||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses,
|
||||
InsufficientQuery {
|
||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryException,
|
||||
QueryNeedsRepairException {
|
||||
ArrayList<ImportKeysListEntry> results = new ArrayList<ImportKeysListEntry>();
|
||||
|
||||
if (query.startsWith("0x")) {
|
||||
@ -84,6 +84,7 @@ public class KeybaseKeyserver extends Keyserver {
|
||||
}
|
||||
|
||||
private ImportKeysListEntry makeEntry(JSONObject match) throws QueryException, JSONException {
|
||||
|
||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||
entry.setQuery(mQuery);
|
||||
|
||||
|
@ -32,20 +32,23 @@ public abstract class Keyserver {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TooManyResponses extends Exception {
|
||||
public static class QueryNeedsRepairException extends Exception {
|
||||
private static final long serialVersionUID = 2693768928624654512L;
|
||||
}
|
||||
|
||||
public static class TooManyResponsesException extends QueryNeedsRepairException {
|
||||
private static final long serialVersionUID = 2703768928624654513L;
|
||||
}
|
||||
|
||||
public static class InsufficientQuery extends Exception {
|
||||
private static final long serialVersionUID = 2703768928624654514L;
|
||||
public static class QueryTooShortException extends QueryNeedsRepairException {
|
||||
}
|
||||
|
||||
public static class AddKeyException extends Exception {
|
||||
private static final long serialVersionUID = -507574859137295530L;
|
||||
}
|
||||
|
||||
abstract List<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses,
|
||||
InsufficientQuery;
|
||||
abstract List<ImportKeysListEntry> search(String query) throws QueryException,
|
||||
QueryNeedsRepairException;
|
||||
|
||||
abstract String get(String keyIdHex) throws QueryException;
|
||||
|
||||
|
@ -273,38 +273,28 @@ public class ImportKeysListFragment extends ListFragment implements
|
||||
break;
|
||||
|
||||
case LOADER_ID_SERVER_QUERY:
|
||||
case LOADER_ID_KEYBASE:
|
||||
|
||||
// TODO: possibly fine-tune message building for these two cases
|
||||
if (error == null) {
|
||||
AppMsg.makeText(
|
||||
getActivity(), getResources().getQuantityString(R.plurals.keys_found,
|
||||
mAdapter.getCount(), mAdapter.getCount()),
|
||||
AppMsg.STYLE_INFO
|
||||
).show();
|
||||
} else if (error instanceof Keyserver.InsufficientQuery) {
|
||||
} else if (error instanceof Keyserver.QueryTooShortException) {
|
||||
AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query,
|
||||
AppMsg.STYLE_ALERT).show();
|
||||
} else if (error instanceof Keyserver.QueryException) {
|
||||
AppMsg.makeText(getActivity(), R.string.error_keyserver_query,
|
||||
AppMsg.STYLE_ALERT).show();
|
||||
} else if (error instanceof Keyserver.TooManyResponses) {
|
||||
String alert = getActivity().getString(R.string.error_searching_keys);
|
||||
alert = alert + " (" + error.getLocalizedMessage() + ")";
|
||||
AppMsg.makeText(getActivity(), alert, AppMsg.STYLE_ALERT).show();
|
||||
} else if (error instanceof Keyserver.TooManyResponsesException) {
|
||||
AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses,
|
||||
AppMsg.STYLE_ALERT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
case LOADER_ID_KEYBASE:
|
||||
|
||||
if (error == null) {
|
||||
AppMsg.makeText(
|
||||
getActivity(), getResources().getQuantityString(R.plurals.keys_found,
|
||||
mAdapter.getCount(), mAdapter.getCount()),
|
||||
AppMsg.STYLE_INFO
|
||||
).show();
|
||||
} else if (error instanceof Keyserver.QueryException) {
|
||||
AppMsg.makeText(getActivity(), R.string.error_keyserver_query,
|
||||
AppMsg.STYLE_ALERT).show();
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -94,14 +94,10 @@ public class ImportKeysListKeybaseLoader
|
||||
|
||||
mEntryList.addAll(searchResult);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||
} catch (Keyserver.InsufficientQuery e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (Keyserver.QueryException e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (Keyserver.TooManyResponses e) {
|
||||
} catch (Keyserver.QueryNeedsRepairException e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,11 +116,9 @@ public class ImportKeysListServerLoader
|
||||
mEntryList.addAll(searchResult);
|
||||
}
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||
} catch (Keyserver.InsufficientQuery e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (Keyserver.QueryException e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (Keyserver.TooManyResponses e) {
|
||||
} catch (Keyserver.QueryNeedsRepairException e) {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
}
|
||||
}
|
||||
|
@ -295,9 +295,9 @@
|
||||
<string name="error_jelly_bean_needed">You need Android 4.1 to use Android\'s NFC Beam feature!</string>
|
||||
<string name="error_nfc_needed">NFC is not available on your device!</string>
|
||||
<string name="error_nothing_import">Nothing to import!</string>
|
||||
<string name="error_keyserver_insufficient_query">Insufficient server query</string>
|
||||
<string name="error_keyserver_query">Querying keyserver failed</string>
|
||||
<string name="error_keyserver_too_many_responses">Too many possible keys. Please refine your query!</string>
|
||||
<string name="error_keyserver_insufficient_query">Key search query too short</string>
|
||||
<string name="error_searching_keys">Unrecoverable error searching for keys at server</string>
|
||||
<string name="error_keyserver_too_many_responses">Key search query returned too many candidates; Please refine query</string>
|
||||
<string name="error_import_file_no_content">File has no content</string>
|
||||
<string name="error_generic_report_bug">A generic error occurred, please create a new bug report for OpenKeychain.</string>
|
||||
<plurals name="error_import_non_pgp_part">
|
||||
|
Loading…
Reference in New Issue
Block a user