CurrencyAlertClassic/KamiLib/Hooking/Safety.cs

33 lines
896 B
C#
Raw Normal View History

2023-10-13 09:38:52 +00:00
using System;
using System.Diagnostics;
using System.Reflection;
using Dalamud.Logging;
namespace KamiLib.Hooking;
public static class Safety
{
public static void ExecuteSafe(Action action, string? message = null)
{
try
{
action();
}
catch (Exception exception)
{
var trace = new StackTrace().GetFrame(1);
var callingAssembly = Assembly.GetCallingAssembly().GetName().Name;
if (trace is not null)
{
var callingClass = trace.GetMethod()?.DeclaringType;
var callingName = trace.GetMethod()?.Name;
//PluginLog.Error($"Exception Source: {callingAssembly} :: {callingClass} :: {callingName}");
2023-10-13 09:38:52 +00:00
}
//PluginLog.Error(exception, message ?? "Caught Exception Safely");
2023-10-13 09:38:52 +00:00
}
}
}