Custom data is not send along
Jan-Paul Mannee
Posted on
Oct 03 2016
Hi,
I want to make use of the userCustomData to send along key value pairs with an exception.
But no data is send, this is my code:
userCustomerData = new Dictionary < string, string > ();
userCustomerData.Add("TestKey1", "Test value 1");
userCustomerData.Add("TestKey2", "Test value 2");
new RaygunClient().SendInBackground(ex, null, userCustomerData);
I can see the exception in the Raygun dashboard, but there is no custom data in it.
Jason Fauchelle
Raygun
Posted on
Oct 04 2016
Hi Jan-Paul,
Thanks for contacting us about this. This usually happens when the same Exception instance is sent twice - first automatically, and then again manually. This is possible if you listen to unhandled exceptions and manually send them where Raygun4Net has been set up to do the same. Raygun4Net marks sent Exception instances so that they can not be double sent - which is easy to do and would chew up your monthly error count.
The recommended way to send custom data with unhandled exceptions is to continue allowing Raygun4Net to send them automatically, but intercept the message before it is sent to Raygun and attach the custom data at that point. This can be done by attaching an event handler to the SendingMessage event of the RaygunClient that is used to send unhandled exceptions automatically. Here is documentation related to this, but instead of setting e.Cancel = true, you'll want to modify the message object to add the custom data. (Not sure what provider you are using, this is the ASP.NET docs) https://raygun.com/docs/languages/net/asp#modify-cancel-message
Note that the SendingMessage event gets used for all automatically and manually sent exceptions.
I hope that helps, please let me know if this is not the case for you, or if you need help with the particular Raygun provider (ASP.NET, MVC, WebAPI etc) you are using.
-Jason Fauchelle
Jan-Paul Mannee
Posted on
Oct 05 2016
Hi Jason,
That was the cause indeed. I've setup the event handler now.
But I was adding custom data that was in the HttpContext. And that doesn't work in the event handler as far as I can see, because it runs in a background thread. I guess the only solution for this is to not setup RayGun to listen to unhandled exceptions.
Jan-Paul