From 3c31d78ab80307c3e583bc9e6c9ab5e1b7522139 Mon Sep 17 00:00:00 2001 From: JFronny Date: Fri, 5 Apr 2024 15:34:51 +0200 Subject: [PATCH] fix: catch exceptions during translation service initialization --- src/main/java/io/gitlab/jfronny/googlechat/GoogleChat.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/gitlab/jfronny/googlechat/GoogleChat.java b/src/main/java/io/gitlab/jfronny/googlechat/GoogleChat.java index da75488..609327f 100644 --- a/src/main/java/io/gitlab/jfronny/googlechat/GoogleChat.java +++ b/src/main/java/io/gitlab/jfronny/googlechat/GoogleChat.java @@ -2,6 +2,8 @@ package io.gitlab.jfronny.googlechat; import io.gitlab.jfronny.commons.io.cache.FixedSizeMap; import io.gitlab.jfronny.commons.logging.Logger; +import io.gitlab.jfronny.commons.throwable.Coerce; +import io.gitlab.jfronny.commons.throwable.Try; import io.gitlab.jfronny.libjf.translate.api.Language; import io.gitlab.jfronny.libjf.translate.api.TranslateService; import net.fabricmc.api.EnvType; @@ -30,7 +32,7 @@ public class GoogleChat implements ModInitializer { @Override public void onInitialize() { - ForkJoinPool.commonPool().execute(() -> TRANSLATE_SERVICE = TranslateService.getConfigured()); + ForkJoinPool.commonPool().execute(Try.handle(Coerce.runnable(() -> TRANSLATE_SERVICE = TranslateService.getConfigured()), e -> LOGGER.error("Could not initialize translation service", e))); } public static void onConfigChange() {