From bfa5fe1598a6a60045fe01e589cc5f67cfe35f5a Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sun, 20 Nov 2022 09:55:30 +0000 Subject: [PATCH] Better skin fix error handling Signed-off-by: TheKodeToad --- libraries/launcher/org/prismlauncher/fix/Fixes.java | 13 ++++++++++--- .../org/prismlauncher/fix/skins/SkinFix.java | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libraries/launcher/org/prismlauncher/fix/Fixes.java b/libraries/launcher/org/prismlauncher/fix/Fixes.java index e099b653c..e85bcfd42 100644 --- a/libraries/launcher/org/prismlauncher/fix/Fixes.java +++ b/libraries/launcher/org/prismlauncher/fix/Fixes.java @@ -40,6 +40,7 @@ import java.util.List; import org.prismlauncher.fix.skins.SkinFix; import org.prismlauncher.utils.Parameters; +import org.prismlauncher.utils.logging.Log; public final class Fixes { @@ -48,9 +49,15 @@ public final class Fixes { public static void apply(Parameters params) { List fixes = params.getList("fixes", Collections.emptyList()); - for (Fix fix : FIXES) - if (fixes.contains(fix.getName()) && fix.isApplicable(params)) - fix.apply(); + for (Fix fix : FIXES) { + if (fixes.contains(fix.getName()) && fix.isApplicable(params)) { + try { + fix.apply(); + } catch (Throwable e) { + Log.error("Could not apply " + fix.getName(), e); + } + } + } } } diff --git a/libraries/launcher/org/prismlauncher/fix/skins/SkinFix.java b/libraries/launcher/org/prismlauncher/fix/skins/SkinFix.java index e26dfb6f1..ab978dc58 100644 --- a/libraries/launcher/org/prismlauncher/fix/skins/SkinFix.java +++ b/libraries/launcher/org/prismlauncher/fix/skins/SkinFix.java @@ -71,7 +71,13 @@ public final class SkinFix implements Fix, URLStreamHandlerFactory { @Override public void apply() { - URL.setURLStreamHandlerFactory(this); + try { + URL.setURLStreamHandlerFactory(this); + } catch (Error e) { + Log.warning("Cannot apply skin fix"); + Log.warning("URLStreamHandlerFactory is already set"); + Log.warning("Turning off legacy skin fix in Settings > Miscellaneous will silence the warnings"); + } } @Override