From 7ccd09fa88f2d935b9a4479ecef30dc47149a358 Mon Sep 17 00:00:00 2001 From: Griefed Date: Sun, 18 Jun 2023 10:57:30 +0200 Subject: [PATCH] fix: Improve error display for filters. Not perfect, but better. --- .../src/main/i18n/Gui_en_GB.properties | 2 +- .../components/inclusions/InclusionsEditor.kt | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties b/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties index d3011bdc6..09e3dd00c 100644 --- a/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties +++ b/serverpackcreator-gui/src/main/i18n/Gui_en_GB.properties @@ -154,7 +154,7 @@ createserverpack.gui.inclusions.editor.inclusion=Inclusion-Filter: createserverpack.gui.inclusions.editor.inclusion.info=Regex-expression by which to determine files and directories to include from the specified source. createserverpack.gui.inclusions.editor.exclusion=Exclusion-Filter: createserverpack.gui.inclusions.editor.exclusion.info=Regex-expression by which to determine files and directories to exclude from the specified source. -createserverpack.gui.inclusions.editor.filter.error=Invalid regex: {0} +createserverpack.gui.inclusions.editor.filter.error=Invalid regex:
{0} createserverpack.gui.inclusions.editor.add=Add a new entry createserverpack.gui.inclusions.editor.delete=Delete selected entry createserverpack.gui.inclusions.editor.tip.default=Select an entry on the left to see what would be included!\nThis panel will be filled with a list of all files that would match the source, taking any filters into account.\nThink of it as a preview and check at the same time. diff --git a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/configs/components/inclusions/InclusionsEditor.kt b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/configs/components/inclusions/InclusionsEditor.kt index b5d4d0fd4..7209d2d7b 100644 --- a/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/configs/components/inclusions/InclusionsEditor.kt +++ b/serverpackcreator-gui/src/main/kotlin/de/griefed/serverpackcreator/gui/window/configs/components/inclusions/InclusionsEditor.kt @@ -262,7 +262,12 @@ class InclusionsEditor( inclusionInfo.info() } catch (ex: PatternSyntaxException) { timer.stop() - inclusionInfo.error(Gui.createserverpack_gui_inclusions_editor_filter_error(ex.description)) + var exception = ex.message ?: ex.description + exception = exception + .replace("\t","%20") + .replace("\n","
") + .replace(" "," ") + inclusionInfo.error("${Gui.createserverpack_gui_inclusions_editor_filter_error(exception)}") } } @@ -277,7 +282,12 @@ class InclusionsEditor( exclusionInfo.info() } catch (ex: PatternSyntaxException) { timer.stop() - exclusionInfo.error(Gui.createserverpack_gui_inclusions_editor_filter_error(ex.description)) + var exception = ex.message ?: ex.description + exception = exception + .replace("\t","    ") + .replace("\n","
") + .replace(" "," ") + exclusionInfo.error("${Gui.createserverpack_gui_inclusions_editor_filter_error(exception)}") } }