diff --git a/NebulaModel/Logger/Log.cs b/NebulaModel/Logger/Log.cs index fa7c93d48..f2e187a54 100644 --- a/NebulaModel/Logger/Log.cs +++ b/NebulaModel/Logger/Log.cs @@ -66,6 +66,15 @@ public static void Error(string message) LastErrorMsg = message; if (UIFatalErrorTip.instance != null) { + // Test if current code is executing on the main unity thread + if (BepInEx.ThreadingHelper.Instance.InvokeRequired) + { + // ShowError has Unity API and needs to call on the main thread + BepInEx.ThreadingHelper.Instance.StartSyncInvoke(() => + UIFatalErrorTip.instance.ShowError("[Nebula Error] " + message, "") + ); + return; + } UIFatalErrorTip.instance.ShowError("[Nebula Error] " + message, ""); } } diff --git a/NebulaNetwork/Ngrok/NgrokManager.cs b/NebulaNetwork/Ngrok/NgrokManager.cs index fc1b11da8..f92837681 100644 --- a/NebulaNetwork/Ngrok/NgrokManager.cs +++ b/NebulaNetwork/Ngrok/NgrokManager.cs @@ -298,9 +298,8 @@ public bool IsNgrokActive() _ngrokProcess?.Refresh(); return !_ngrokProcess?.HasExited ?? false; } - catch (Exception e) + catch { - Log.Error(e); return false; } }