© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
2 replies
nullpointer

how to delegate on static method

Hi, I want to delegate from a static method to delegate trapped exceptions from Godot.
By nature, all un-caught exceptions from this block are caught inside Godot and only logged at the end.
 catch (Exception ex)
      {
        ExceptionUtils.LogException(ex);
        *ret = new godot_variant();
        return godot_bool.False;
      }
 catch (Exception ex)
      {
        ExceptionUtils.LogException(ex);
        *ret = new godot_variant();
        return godot_bool.False;
      }

So I want to delegate from
ExceptionUtils.LogException(ex);
ExceptionUtils.LogException(ex);
to my own handler to get the exceptions. I have tried a lot, but to no avail.
The method signature is.
Namespace Godot.NativeInterop
{
  internal static class ExceptionUtils
  {
     public static void LogException(Exception e)
  }
}
Namespace Godot.NativeInterop
{
  internal static class ExceptionUtils
  {
     public static void LogException(Exception e)
  }
}


Currently I'm using a hook to work with
AppDomain.CurrentDomain.FirstChanceException
AppDomain.CurrentDomain.FirstChanceException
, but I only want to catch exceptions from the original Godot catch block.
Here the actual code of my hook https://github.com/MikeSchulze/gdUnit4Net/blob/master/api/src/core/hooks/GodotExceptionHook.cs

Any ideas?
GitHub
gdUnit4Net/api/src/core/hooks/GodotExceptionHook.cs at master · Mik...
A Godot C# Unit Test Framework. Contribute to MikeSchulze/gdUnit4Net development by creating an account on GitHub.
gdUnit4Net/api/src/core/hooks/GodotExceptionHook.cs at master · Mik...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create a `Delegate` from a `MethodInfo` [Answered]
C#CC# / help
4y ago
❔ Static methods
C#CC# / help
3y ago
❔ TargetParameterCountException when trying to create a delegate from a method
C#CC# / help
3y ago
Delegate.CreateDelegate returns "ArgumentException: method arguments are incompatible"
C#CC# / help
2y ago