Feature Request
Serialize Extra Properties On An Exception
Current Status:
Completed
jamie94bc
It'd be nice if the Raygun4Net client would somehow support the extra information given on properties in an exception... For example the below is an entity framework exception:
[DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.] System.Data.Entity.Internal.InternalContext.SaveChangesAsync(CancellationToken cancellationToken):52 System.Data.Entity.Internal.LazyInternalContext.SaveChangesAsync(CancellationToken cancellationToken):15 System.Data.Entity.DbContext.SaveChangesAsync():11
I presume the way to do this would be to use reflection to find extra properties on the exception (or serialize the whole exception?).
Raygun
John-Daniel Trask
Posted on
Nov 12 2013
Hi,
Your best bet is to attach this to the custom data and send it up. You'll see you can attach this on the Send method.
Serializing exceptions doesn't work well as they can end up being many MB in size due to nested exceptions and folks attaching all sorts of custom data. You may also wish to throw a new exception that simply sets the message to be the validation failure messages so they appear more easily on the dashboard (message will match what the actual failing was, rather than EF's generic holder).
I hope that explains what is going on and gives you a path forward.
Kind regards,
John-Daniel Trask
Co-founder
Mindscape Limited
jamie94bc
Posted on
Nov 12 2013
Thanks for your response :)
Yeah that's actually what I'm doing because I had custom logging setup before Raygun; all errors/exceptions are funnelled into one place - I thought this may not be the case for people who use the HttpHandler.
Perhaps an event could be added to the RaygunClient
that would allow custom data to be added? Or you could derive from RaygunClient
and override the message builder?
Raygun
Jason Fauchelle
Posted on
Jul 03 2015
Missed updating this earlier, but replying for completeness: The RaygunClient in Raygun4Net was later updated to include an event called SendingMessage. This can be used to modify any of the information about to be sent to Raygun. This is a good centralized place for attaching custom data such as extra values on certain exception types. Relevent docs: https://raygun.io/docs/languages/net/asp#modify-cancel-message
austingrigg
Posted on
Aug 02 2018
How do you get the original error from within the SendingMessage event handler? I don't see a way to access the original Exception, which is needed to inspect if it is a DbEntityValidationException and to pull out the additional info to pass on to Raygun.
Raygun
Jason Fauchelle
Posted on
Aug 02 2018
Hi austingrigg,
Thanks for pointing this out, we certainly overlooked this. I've logged this addition for prioritization in a future version of Raygun4Net. I do not know when we'll add this, so as a work around, you can use the CustomGroupingKey event which has both the Raygun message that you can augment, along with the original exception.
-Jason Fauchelle