mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-11 01:37:24 +01:00
Show unhandled exceptions through VEH
This commit is contained in:
parent
caa869d3ac
commit
b35faf13b5
5 changed files with 40 additions and 23 deletions
|
|
@ -453,3 +453,9 @@ void veh::raise_external_event(const std::wstring& info)
|
|||
wcsncpy_s(g_external_event_info, info.c_str(), info_size);
|
||||
RaiseException(CUSTOM_EXCEPTION_EXTERNAL_EVENT, 0, 0, nullptr);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void BootVehRaiseExternalEventW(LPCWSTR info)
|
||||
{
|
||||
const std::wstring info_wstr(info);
|
||||
veh::raise_external_event(info_wstr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,7 +292,6 @@ public sealed class EntryPoint
|
|||
}
|
||||
|
||||
var pluginInfo = string.Empty;
|
||||
var supportText = ", please visit us on Discord for more help";
|
||||
try
|
||||
{
|
||||
var pm = Service<PluginManager>.GetNullable();
|
||||
|
|
@ -300,9 +299,6 @@ public sealed class EntryPoint
|
|||
if (plugin != null)
|
||||
{
|
||||
pluginInfo = $"Plugin that caused this:\n{plugin.Name}\n\nClick \"Yes\" and remove it.\n\n";
|
||||
|
||||
if (plugin.IsThirdParty)
|
||||
supportText = string.Empty;
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
@ -310,31 +306,18 @@ public sealed class EntryPoint
|
|||
// ignored
|
||||
}
|
||||
|
||||
const MESSAGEBOX_STYLE flags = MESSAGEBOX_STYLE.MB_YESNO | MESSAGEBOX_STYLE.MB_ICONERROR | MESSAGEBOX_STYLE.MB_SYSTEMMODAL;
|
||||
var result = Windows.Win32.PInvoke.MessageBox(
|
||||
new HWND(Process.GetCurrentProcess().MainWindowHandle),
|
||||
$"An internal error in a Dalamud plugin occurred.\nThe game must close.\n\n{ex.GetType().Name}\n{info}\n\n{pluginInfo}More information has been recorded separately{supportText}.\n\nDo you want to disable all plugins the next time you start the game?",
|
||||
"Dalamud",
|
||||
flags);
|
||||
|
||||
if (result == MESSAGEBOX_RESULT.IDYES)
|
||||
{
|
||||
Log.Information("User chose to disable plugins on next launch...");
|
||||
var config = Service<DalamudConfiguration>.Get();
|
||||
config.PluginSafeMode = true;
|
||||
config.ForceSave();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(-1);
|
||||
|
||||
ErrorHandling.CrashWithContext($"{ex}\n\n{info}\n\n{pluginInfo}");
|
||||
break;
|
||||
default:
|
||||
Log.Fatal("Unhandled SEH object on AppDomain: {Object}", args.ExceptionObject);
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
private static void OnUnhandledExceptionStallDebug(object sender, UnhandledExceptionEventArgs args)
|
||||
|
|
|
|||
|
|
@ -667,6 +667,8 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
{
|
||||
if (this.isImGuiDrawDevMenu)
|
||||
{
|
||||
using var barColor = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0.060f, 0.060f, 0.060f, 0.773f));
|
||||
barColor.Push(ImGuiCol.MenuBarBg, Vector4.Zero);
|
||||
if (ImGui.BeginMainMenuBar())
|
||||
{
|
||||
var pluginManager = Service<PluginManager>.Get();
|
||||
|
|
@ -839,6 +841,11 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
ImGui.PopStyleVar();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Raise external event through boot"))
|
||||
{
|
||||
ErrorHandling.CrashWithContext("Tést");
|
||||
}
|
||||
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
||||
|
|
|
|||
21
Dalamud/Utility/ErrorHandling.cs
Normal file
21
Dalamud/Utility/ErrorHandling.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Utilities for handling errors inside Dalamud.
|
||||
/// </summary>
|
||||
internal static partial class ErrorHandling
|
||||
{
|
||||
/// <summary>
|
||||
/// Crash the game at this point, and show the crash handler with the supplied context.
|
||||
/// </summary>
|
||||
/// <param name="context">The context to show in the crash handler.</param>
|
||||
public static void CrashWithContext(string context)
|
||||
{
|
||||
BootVehRaiseExternalEvent(context);
|
||||
}
|
||||
|
||||
[LibraryImport("Dalamud.Boot.dll", EntryPoint = "BootVehRaiseExternalEventW", StringMarshalling = StringMarshalling.Utf16)]
|
||||
private static partial void BootVehRaiseExternalEvent(string info);
|
||||
}
|
||||
|
|
@ -1014,8 +1014,8 @@ int main() {
|
|||
config.pButtons = buttons;
|
||||
config.cButtons = ARRAYSIZE(buttons);
|
||||
config.nDefaultButton = IdButtonRestart;
|
||||
config.pszExpandedControlText = L"Hide stack trace";
|
||||
config.pszCollapsedControlText = L"Stack trace for plugin developers";
|
||||
config.pszExpandedControlText = L"Hide further information";
|
||||
config.pszCollapsedControlText = L"Further information for developers";
|
||||
config.pszExpandedInformation = window_log_str.c_str();
|
||||
config.pszWindowTitle = L"Dalamud Crash Handler";
|
||||
config.pRadioButtons = radios;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue