Exception Serialization

tbowers

Posted on
Jun 07 2014

When an Exception is sent to Raygun, how is the stack trace information captured and sent? Is the .Message, .StackTrace or ToString() property/methods called?

I'd like to hook into this for my own customer exceptions and provide additional information to be captured by the dashboard.


Jason Fauchelle

Raygun

Posted on
Jun 09 2014

Hello

For .Net 3.5+ projects, we create a new StackTrace object by passing the exception into the StackTrace constructor, and get the information from there: https://github.com/MindscapeHQ/raygun4net/blob/master/Mindscape.Raygun4Net/Messages/RaygunErrorMessage.cs#L36

This approach seems to provide the same amount of information as calling ToString(), including scenarios involving async operations. (As opposed to some of our other .Net based providers where ToString() provides additional frames when there are async methods involved).

We recently added an event called SendingMessage to the RaygunClient class. You can attach an event handler to this method which will give you the RaygunMessage object just before serializing and sending it. This allows you to modify any part of the message such as all the stack trace frames. If you don't see this event on RaygunClient, simply update to the latest version of the NuGet package - as this feature is quite new.

Alternatively, you can send additional data by passing it into one of the RaygunClient.Send method overloads. This is placed on a CustomData section in the raygun message.

Let me know if you have further questions about this.

-Jason Fauchelle


tbowers

Posted on
Jun 10 2014

Jason,

Thanks for getting back to me! This is great stuff, we'll investigate its use immediately.

Thanks, Travis


Reply