godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs
Ignacio Roldán Etcheverry 50b603c7dc C#: Begin move to .NET Core
We're targeting .NET 5 for now to make development easier while
.NET 6 is not yet released.

TEMPORARY REGRESSIONS
---------------------

Assembly unloading is not implemented yet. As such, many Godot
resources are leaked at exit. This will be re-implemented later
together with assembly hot-reloading.
2021-09-22 08:27:12 +02:00

75 lines
2.1 KiB
C#

using System;
namespace Godot.NativeInterop
{
internal static class ExceptionUtils
{
public static void PushError(string message)
{
GD.PushError(message);
}
private static void OnExceptionLoggerException(Exception loggerException, Exception exceptionToLog)
{
// This better not throw
PushError("Exception thrown when trying to log another exception...");
PushError("Exception:");
PushError(exceptionToLog.ToString());
PushError("Logger exception:");
PushError(loggerException.ToString());
}
public static void DebugPrintUnhandledException(Exception e)
{
try
{
// TODO Not implemented (debug_print_unhandled_exception)
GD.PushError(e.ToString());
}
catch (Exception unexpected)
{
OnExceptionLoggerException(unexpected, e);
}
}
public static void DebugSendUnhandledExceptionError(Exception e)
{
try
{
// TODO Not implemented (debug_send_unhandled_exception_error)
GD.PushError(e.ToString());
}
catch (Exception unexpected)
{
OnExceptionLoggerException(unexpected, e);
}
}
public static void DebugUnhandledException(Exception e)
{
try
{
// TODO Not implemented (debug_unhandled_exception)
GD.PushError(e.ToString());
}
catch (Exception unexpected)
{
OnExceptionLoggerException(unexpected, e);
}
}
public static void PrintUnhandledException(Exception e)
{
try
{
// TODO Not implemented (print_unhandled_exception)
GD.PushError(e.ToString());
}
catch (Exception unexpected)
{
OnExceptionLoggerException(unexpected, e);
}
}
}
}