From 4338d9dfbb1eddc6e3896ddc745f92429988cedd Mon Sep 17 00:00:00 2001 From: Kevin Klein Date: Sun, 9 Oct 2022 12:16:19 +0200 Subject: [PATCH 1/3] Log exception --- CHANGELOG.md | 1 + .../gui/importer/GenerateEntryFromIdAction.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 895a48815ec..e47cbd43648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where pdfs were re-indexed on each startup. [#9166](https://github.com/JabRef/jabref/pull/9166) - We fixed an issue where Capitalize didn't capitalize words after hyphen characters. [#9157](https://github.com/JabRef/jabref/issues/9157) - We fixed an issue with the message that is displayed when fetcher returns an empty list of entries for given query. [#9195](https://github.com/JabRef/jabref/issues/9195) +- We fixed an issue where an exception was not logged correctly. [#627](https://github.com/JabRef/koppor/issues/627) ### Removed diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java index 95e2eb99d53..1077b3c4298 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java @@ -20,8 +20,11 @@ import org.jabref.preferences.PreferencesService; import org.controlsfx.control.PopOver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GenerateEntryFromIdAction extends SimpleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(GenerateEntryFromIdAction.class); private final LibraryTab libraryTab; private final DialogService dialogService; @@ -56,15 +59,18 @@ public void execute() { backgroundTask.onFailure((exception) -> { String fetcherExceptionMessage = exception.getMessage(); - boolean addEntryFlag; + String msg; if (exception instanceof FetcherClientException) { - addEntryFlag = dialogService.showConfirmationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Bibliographic data not found. Cause is likely the client side. Please check connection and identifier for correctness.") + "\n" + fetcherExceptionMessage, Localization.lang("Add entry manually")); + msg = Localization.lang("Bibliographic data not found. Cause is likely the client side. Please check connection and identifier for correctness.") + "\n" + fetcherExceptionMessage; } else if (exception instanceof FetcherServerException) { - addEntryFlag = dialogService.showConfirmationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try agan later.") + "\n" + fetcherExceptionMessage, Localization.lang("Add entry manually")); + msg = Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try agan later.") + "\n" + fetcherExceptionMessage; } else { - addEntryFlag = dialogService.showConfirmationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Error message %0", fetcherExceptionMessage), Localization.lang("Add entry manually")); + msg = Localization.lang("Error message %0", fetcherExceptionMessage); } - if (addEntryFlag) { + + LOGGER.info(fetcherExceptionMessage, exception); + + if (dialogService.showConfirmationDialogAndWait(Localization.lang("Failed to import by ID"), msg, Localization.lang("Add entry manually"))) { // add entry manually new NewEntryAction(libraryTab.frame(), StandardEntryType.Article, dialogService, preferencesService, stateManager).execute(); From 017c8d5e16fde52936725a2b945732fe77a8e6cc Mon Sep 17 00:00:00 2001 From: Kevin Klein Date: Mon, 10 Oct 2022 08:35:17 +0200 Subject: [PATCH 2/3] Fix typo --- src/main/java/org/jabref/gui/EntryTypeViewModel.java | 2 +- .../java/org/jabref/gui/importer/GenerateEntryFromIdAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java index 7e08b6857e2..233c1a8edcb 100644 --- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java @@ -150,7 +150,7 @@ public void runFetcherWorker() { if (exception instanceof FetcherClientException) { dialogService.showInformationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Bibliographic data not found. Cause is likely the client side. Please check connection and identifier for correctness.") + "\n" + fetcherExceptionMessage); } else if (exception instanceof FetcherServerException) { - dialogService.showInformationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try agan later.") + "\n" + fetcherExceptionMessage); + dialogService.showInformationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try again later.") + "\n" + fetcherExceptionMessage); } else { dialogService.showInformationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Error message %0", fetcherExceptionMessage)); } diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java index 1077b3c4298..7e7d657f705 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java @@ -63,7 +63,7 @@ public void execute() { if (exception instanceof FetcherClientException) { msg = Localization.lang("Bibliographic data not found. Cause is likely the client side. Please check connection and identifier for correctness.") + "\n" + fetcherExceptionMessage; } else if (exception instanceof FetcherServerException) { - msg = Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try agan later.") + "\n" + fetcherExceptionMessage; + msg = Localization.lang("Bibliographic data not found. Cause is likely the server side. Please try again later.") + "\n" + fetcherExceptionMessage; } else { msg = Localization.lang("Error message %0", fetcherExceptionMessage); } From 58ac8463c73bd39f66cd7cfa12250788b11610ed Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 10 Oct 2022 18:06:23 +0200 Subject: [PATCH 3/3] fix l10n test --- src/main/resources/l10n/JabRef_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index bb1ae785eeb..2ac871e6ecc 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2456,7 +2456,7 @@ Server\ not\ available=Server not available Fetching\ information\ using\ %0=Fetching information using %0 Look\ up\ identifier=Look up identifier Bibliographic\ data\ not\ found.\ Cause\ is\ likely\ the\ client\ side.\ Please\ check\ connection\ and\ identifier\ for\ correctness.=Bibliographic data not found. Cause is likely the client side. Please check connection and identifier for correctness. -Bibliographic\ data\ not\ found.\ Cause\ is\ likely\ the\ server\ side.\ Please\ try\ agan\ later.=Bibliographic data not found. Cause is likely the server side. Please try agan later. +Bibliographic\ data\ not\ found.\ Cause\ is\ likely\ the\ server\ side.\ Please\ try\ again\ later.=Bibliographic data not found. Cause is likely the server side. Please try again later. Error\ message\ %0=Error message %0 Identifier\ not\ found=Identifier not found