Raygun Feature Request

Feature Request

Custom serialisers/transforms for Exception types.

Current Status:

New

Votes:

1


Avatar

k3r

Hi!

This subject has come up before, in this suggestion, but it doesn't look as though the issue was conclusively resolved. Or maybe I'm barking up the wrong tree?

I'd like to be able to create project wide tranforms for specific Exception types. The example that comes up a lot is DbEntityValidationException, which has the extra EntityValidationErrors property. Based on the previously mentioned suggestion, our current solution is below. It's not ideal, at the very least the situation would be much improved by exposing the original exception in the SendingMessage event. What would be really neat though, is if you could register transformation(?) functions against specific Exception types, using a quasi DI pattern maybe?

Rich

Imports System.Data.Entity.Validation
Imports System.Web.Http
Imports Mindscape.Raygun4Net
Imports Mindscape.Raygun4Net.Messages
Imports Mindscape.Raygun4Net.WebApi

Public Module WebApiConfig

    Private _raygunClient As RaygunWebApiClient

    Private _lastException As Exception = Nothing

    Private Sub RaygunCustomGroupingKey(sender As RaygunWebApiClient, args As RaygunCustomGroupingKeyEventArgs)
        _lastException = args.Exception
    End Sub

    Private Sub RaygunSendingMessage(sender As RaygunWebApiClient, args As RaygunSendingMessageEventArgs)
        If _lastException Is Nothing Then
            Exit Sub
        End If

        Dim dbException As DbEntityValidationException = _lastException
        If dbException IsNot Nothing AndAlso dbException.EntityValidationErrors.Any() Then
            Dim errors As New List(Of String)

            For Each eve In dbException.EntityValidationErrors
                For Each ve In eve.ValidationErrors
                    errors.Add(ve.ErrorMessage)
                Next
            Next

            args.Message.Details.Error.Data.Add("EntityValidationErrors", errors)
        End If

        _lastException = Nothing
    End Sub

    Public Sub Register(config As HttpConfiguration)
        RaygunWebApiClient.Attach(config, Function()
                                              If IsNothing(_raygunClient) Then
                                                  _raygunClient = New RaygunWebApiClient()

                                                  AddHandler _raygunClient.CustomGroupingKey, AddressOf RaygunCustomGroupingKey
                                                  AddHandler _raygunClient.SendingMessage, AddressOf RaygunSendingMessage
                                              End If

                                              ' UserInfo here

                                              Return _raygunClient
                                          End Function)

        config.MapHttpAttributeRoutes()

        ' Routing here
    End Sub

End Module

Avatar

Raygun

Deleted User

Posted on
Jun 12 2020

Hi k3r,

Thank you for getting in touch with us. We agree it would be great to provide more ways of extracting information from the various exception types.

I think you raised a good point that the situation would be improved by exposing the original exception in the SendingMessage event. I have created an internal ticket to address this functionality in the Raygun4Net provider. Once the exception is exposed you will have the opportunity to implement custom transformers.

Once we expose the original exception we can look to reevaluate whether custom serialisers or transformers are a desired feature in the community.

Thank you, Mitchell.