diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java index 342d7e61fc3..5775916238d 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java @@ -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 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())); + } + } }