Fix gestione allegati e creato metodo di esportazione log

This commit is contained in:
2026-03-04 11:51:42 +01:00
parent 3760e38c8d
commit 2d938fb210
26 changed files with 986 additions and 384 deletions

View File

@@ -0,0 +1,37 @@
using Microsoft.Extensions.Logging;
namespace SteUp.Maui.Core.UtilityException;
public static class GlobalExceptionHandler
{
public static void Register(ILogger logger)
{
AppDomain.CurrentDomain.UnhandledException += (_, args) =>
{
var ex = args.ExceptionObject as Exception;
logger.LogCritical(ex, "UnhandledException (AppDomain) — IsTerminating: {t}", args.IsTerminating);
};
TaskScheduler.UnobservedTaskException += (_, args) =>
{
logger.LogCritical(args.Exception, "UnobservedTaskException");
args.SetObserved();
};
#if ANDROID
Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += (_, args) =>
{
logger.LogCritical(args.Exception, "Android UnhandledException");
args.Handled = true;
};
#endif
#if IOS || MACCATALYST
ObjCRuntime.Runtime.MarshalManagedException += (_, args) =>
{
logger.LogCritical(args.Exception, "iOS MarshalManagedException");
args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
};
#endif
}
}