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;
|
|
|
|
|
|
2024-07-09 21:01:17 +00:00
|
|
|
|
//PluginLog.Error($"Exception Source: {callingAssembly} :: {callingClass} :: {callingName}");
|
2023-10-13 09:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 21:01:17 +00:00
|
|
|
|
//PluginLog.Error(exception, message ?? "Caught Exception Safely");
|
2023-10-13 09:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-09 21:01:17 +00:00
|
|
|
|
}
|