mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
feat: add error handling for plugins that throw while drawing
This commit is contained in:
parent
5571c849c5
commit
e3d6b91d8b
1 changed files with 26 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using ImGuiScene;
|
using ImGuiScene;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface
|
namespace Dalamud.Interface
|
||||||
{
|
{
|
||||||
|
|
@ -74,9 +75,33 @@ namespace Dalamud.Interface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EventHandler OnOpenConfigUi;
|
public EventHandler OnOpenConfigUi;
|
||||||
|
|
||||||
|
private bool hasErrorWindow;
|
||||||
|
|
||||||
private void OnDraw() {
|
private void OnDraw() {
|
||||||
ImGui.PushID(this.namespaceName);
|
ImGui.PushID(this.namespaceName);
|
||||||
OnBuildUi?.Invoke();
|
|
||||||
|
if (this.hasErrorWindow && ImGui.Begin(string.Format("{0} Error", this.namespaceName), ref this.hasErrorWindow,
|
||||||
|
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize)) {
|
||||||
|
ImGui.Text(string.Format("The plugin {0} ran into an error.\nContact the plugin developer for support.\n\nPlease try restarting your game.", this.namespaceName));
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
if (ImGui.Button("OK")) {
|
||||||
|
this.hasErrorWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
OnBuildUi?.Invoke();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.Error("[{0}] UiBuilder OnBuildUi caught exception");
|
||||||
|
OnBuildUi = null;
|
||||||
|
OnOpenConfigUi = null;
|
||||||
|
|
||||||
|
this.hasErrorWindow = true;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.PopID();
|
ImGui.PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue