From 6061ff7ba11d3123bc4a2d7981a31b735f5dcf8d Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Thu, 18 Feb 2021 16:18:33 +0100 Subject: Added mono_unhandled_exception call to unhandled_exception hook --- .../GodotSharp/Core/GodotUnhandledExceptionEvent.cs | 21 +++++++++++++++++++++ .../GodotSharp/Core/UnhandledExceptionArgs.cs | 20 ++++++++++++++++++++ .../glue/GodotSharp/GodotSharp/GodotSharp.csproj | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs (limited to 'modules/mono/glue') 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 + { + /// + /// Fires when an unhandled exception occurs, regardless of project settings. + /// + public static event EventHandler 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 +{ + /// + /// Event arguments for when unhandled exceptions occur. + /// + public class UnhandledExceptionArgs + { + /// + /// Exception object + /// + 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 7c1a23d510..a7aa977720 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -37,6 +37,7 @@ + @@ -56,6 +57,7 @@ + -- cgit v1.2.3