Skip to content

Commit 3945c6a

Browse files
committed
Adding a Houston to MM when a Reflection error happens
1 parent be17df2 commit 3945c6a

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

Source/ModuleManager/ExceptionIntercept/InterceptLogHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void LogException(Exception exception, Object context)
4040
var assemblies = ex.Types.Where(x => x != null).Select(x => x.Assembly).Distinct();
4141
foreach (Assembly assembly in assemblies)
4242
{
43-
if (Warnings == "")
43+
if (string.IsNullOrEmpty(Warnings))
4444
{
4545
Warnings = "Add'On(s) DLL that have failed to be dynamically linked on loading\n";
4646
}
@@ -58,7 +58,8 @@ public void LogException(Exception exception, Object context)
5858
{
5959
message += "Exception " + e.GetType().Name + " while handling the exception...";
6060
}
61-
Logging.ModLogger.LOG.info(message);
61+
Logging.ModLogger.LOG.error("**FATAL** {0}", message);
62+
GUI.ShowStopperAlertBox.Show(message);
6263
}
6364
}
6465
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
This file is part of Module Manager /L
3+
(C) 2020 Lisias T : http://lisias.net <[email protected]>
4+
5+
Module Manager /L is distributed in the hope that it will be useful,
6+
but WITHOUT ANY WARRANTY; without even the implied warranty of
7+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+
*/
9+
using UnityEngine;
10+
11+
namespace ModuleManager.GUI
12+
{
13+
internal static class ShowStopperAlertBox
14+
{
15+
private static readonly string MSG = @"*THIS IS NOT* the Forum's Module Manager from Sarbian & Blowfish - don't bother them about this.
16+
17+
{0}";
18+
19+
private static readonly string AMSG = @"call for help on the Module Manager /L GitHub page (KSP will close). We will help you on diagnosing the Add'On that is troubling you. ";
20+
21+
internal static void Show(string message)
22+
{
23+
KSPe.Common.Dialogs.ShowStopperAlertBox.Show(
24+
string.Format(MSG, message),
25+
AMSG,
26+
() => { Application.OpenURL("https://github.com/net-lisias-ksp/ModuleManager/issues/2"); Application.Quit(); }
27+
);
28+
Logging.ModLogger.LOG.info("\"Houston, we have a Problem!\" was displayed");
29+
}
30+
}
31+
}

Source/ModuleManager/ModuleManager.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<Compile Include="Patches\PassSpecifiers\LastPassSpecifier.cs" />
109109
<Compile Include="Startup.cs" />
110110
<Compile Include="ExceptionIntercept\InterceptLogHandler.cs" />
111+
<Compile Include="GUI\ShowStopperAlertBox.cs" />
111112
</ItemGroup>
112113
<ItemGroup>
113114
<Reference Include="System" />
@@ -124,6 +125,9 @@
124125
<Reference Include="UnityEngine">
125126
<HintPath>..\..\..\..\..\..\LIB\managed\1.3.1\UnityEngine.dll</HintPath>
126127
</Reference>
128+
<Reference Include="KSPe.UI">
129+
<HintPath>..\..\..\..\..\..\LIB\plugins\KSPe.UI.dll</HintPath>
130+
</Reference>
127131
</ItemGroup>
128132
<ItemGroup>
129133
<EmbeddedResource Include="Properties\Resources.resx" />

0 commit comments

Comments
 (0)