Skip to content

Also report exception HResult #3939

@whiskhub

Description

@whiskhub

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 }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions