Problem Statement
Some exceptions, especially COMException or Win32Exception, sometimes do not provide a good exception message which makes it hard to analyze issues on Sentry. COMException even often returns an empty exception message.
However, in .NET every Exception object has a HResult property. Especially for the cases mentioned above, this value would be worth a lot as it contains the concrete error type (e.g. -2147417842 -> RPC_E_WRONG_THREAD). This HResult property is currently not sent with a Sentry event.
Therefore I would like to request the HResult property of an Exception to also be uploaded in a SentryEvent, and that its value is also visible in the Sentry web UI.
Solution Brainstorm
According to your documentation, such information could be stored in the Exception.Mechanism.Meta field (https://develop.sentry.dev/sdk/data-model/event-payloads/exception/#meta-information).
However, there are currently only Linux/Apple specific definitions listed, like signal or mach_exception. A definition for a Windows HResult, or more generally HResult (as they may also be used in cross-platform .NET apps), should be added there.
Using ISentryEventExceptionProcessor I already tried manually adding some HResult field to the Meta. However, it was not displayed in the Sentry web UI. Only when I used errno to "fake" a HResult, it was showing up. So I assume you must also add server-side handling.
For the .NET side, the change should be fairly easy. In the MainExceptionProcessor, something alike should be added:
mechanism.InternalMeta = new()
{
{ "HResult", exception.HResult }
};
Problem Statement
Some exceptions, especially
COMExceptionorWin32Exception, sometimes do not provide a good exception message which makes it hard to analyze issues on Sentry.COMExceptioneven often returns an empty exception message.However, in .NET every
Exceptionobject has aHResultproperty. Especially for the cases mentioned above, this value would be worth a lot as it contains the concrete error type (e.g. -2147417842 -> RPC_E_WRONG_THREAD). ThisHResultproperty is currently not sent with a Sentry event.Therefore I would like to request the
HResultproperty of an Exception to also be uploaded in aSentryEvent, and that its value is also visible in the Sentry web UI.Solution Brainstorm
According to your documentation, such information could be stored in the Exception.Mechanism.Meta field (https://develop.sentry.dev/sdk/data-model/event-payloads/exception/#meta-information).
However, there are currently only Linux/Apple specific definitions listed, like
signalormach_exception. A definition for a Windows HResult, or more generally HResult (as they may also be used in cross-platform .NET apps), should be added there.Using
ISentryEventExceptionProcessorI already tried manually adding someHResultfield to theMeta. However, it was not displayed in the Sentry web UI. Only when I usederrnoto "fake" a HResult, it was showing up. So I assume you must also add server-side handling.For the .NET side, the change should be fairly easy. In the MainExceptionProcessor, something alike should be added: