-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide redundant information on fetcher exception #6569
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import org.jabref.gui.JabRefFrame; | ||
import org.jabref.gui.importer.ImportEntriesDialog; | ||
import org.jabref.gui.util.BackgroundTask; | ||
import org.jabref.logic.importer.FetcherException; | ||
import org.jabref.logic.importer.ImportFormatPreferences; | ||
import org.jabref.logic.importer.ParserResult; | ||
import org.jabref.logic.importer.SearchBasedFetcher; | ||
|
@@ -94,10 +95,22 @@ public void search() { | |
BackgroundTask<ParserResult> task = BackgroundTask.wrap(() -> new ParserResult(activeFetcher.performSearch(getQuery().trim()))) | ||
.withInitialMessage(Localization.lang("Processing %0", getQuery())); | ||
|
||
task.onFailure(dialogService::showErrorDialogAndWait); | ||
task.onFailure(this::exceptionHandler); | ||
|
||
ImportEntriesDialog dialog = new ImportEntriesDialog(frame.getCurrentBasePanel().getBibDatabaseContext(), task); | ||
dialog.setTitle(activeFetcher.getName()); | ||
dialog.showAndWait(); | ||
} | ||
|
||
private void exceptionHandler(Exception exception) { | ||
if (exception instanceof FetcherException) { | ||
if (exception.getMessage().equals("A network error occurred")) { | ||
dialogService.showWarningDialogAndWait(Localization.lang("An error occurred"), | ||
Localization.lang(exception.getMessage() + ". You have no rights to access resources.")); | ||
} | ||
} else { | ||
dialogService.showWarningDialogAndWait(Localization.lang("An error occurred"), | ||
Localization.lang(exception.getMessage())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Background information is available at https://devdocs.jabref.org/getting-into-the-code/code-howtos#using-localization-correctly. |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, please add the strings to the english language resource file.