diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-08 13:26:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 13:26:47 +0100 |
commit | 26d1b30d35d0897e18e4bc9521c1833eb1bdcf0c (patch) | |
tree | ea690bdb1240778edcb5a6bc82e4a06d89cdc850 /modules/mono/glue | |
parent | aa6bbdc7a8ca4dc84a6db227ba72519c99ee1036 (diff) | |
parent | 6061ff7ba11d3123bc4a2d7981a31b735f5dcf8d (diff) |
Merge pull request #46174 from xill47/mono-appdomain-unhandled-exception-event
Added mono_unhandled_exception call to unhandled_exception hook
Diffstat (limited to 'modules/mono/glue')
3 files changed, 43 insertions, 0 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs new file mode 100644 index 0000000000..702a6c76ba --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Godot +{ + public static partial class GD + { + /// <summary> + /// Fires when an unhandled exception occurs, regardless of project settings. + /// </summary> + public static event EventHandler<UnhandledExceptionArgs> UnhandledException; + + private static void OnUnhandledException(Exception e) + { + UnhandledException?.Invoke(null, new UnhandledExceptionArgs(e)); + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs new file mode 100644 index 0000000000..be01674568 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs @@ -0,0 +1,20 @@ +using System; + +namespace Godot +{ + /// <summary> + /// Event arguments for when unhandled exceptions occur. + /// </summary> + public class UnhandledExceptionArgs + { + /// <summary> + /// Exception object + /// </summary> + public Exception Exception { get; private set; } + + internal UnhandledExceptionArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index e98eabaff2..54aaaf1f92 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -40,6 +40,7 @@ <Compile Include="Core\GodotSynchronizationContext.cs" /> <Compile Include="Core\GodotTaskScheduler.cs" /> <Compile Include="Core\GodotTraceListener.cs" /> + <Compile Include="Core\GodotUnhandledExceptionEvent.cs" /> <Compile Include="Core\Interfaces\IAwaitable.cs" /> <Compile Include="Core\Interfaces\IAwaiter.cs" /> <Compile Include="Core\Interfaces\ISerializationListener.cs" /> @@ -59,6 +60,7 @@ <Compile Include="Core\StringName.cs" /> <Compile Include="Core\Transform.cs" /> <Compile Include="Core\Transform2D.cs" /> + <Compile Include="Core\UnhandledExceptionArgs.cs" /> <Compile Include="Core\Vector2.cs" /> <Compile Include="Core\Vector2i.cs" /> <Compile Include="Core\Vector3.cs" /> |