internal static void HandleException(Exception exception, ModLogger logger = null, LogType type = LogType.CRITICAL) { if (handledException != null) { return; } string message = $"{(!exception.Message.Matches(@"^(?:(?!Exception:).)*Exception:(?!.*Exception:).*$") ? exception.GetType().Name + ": " : string.Empty)}{ReplaceInnerIfPresent(exception.Message, exception.InnerException)}"; if (!string.IsNullOrWhiteSpace(exception.StackTrace)) { message += $"\n{StackTracing.ParseStackTrace(new StackTrace(exception, true)).TrimEnd('\n')}"; } (logger ?? GuuCore.LOGGER)?.Log(type, message); File.Copy(UNITY_LOG_FILE, NEW_UNITY_LOG_FILE, true); if (type == LogType.CRITICAL) { handledException = exception; reportWindow.Open(); } }