Floyddotnet / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

Code to allow custom rendering of an exception #206

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We needed to be able to print more info from exceptions than e.ToString() and 
had a class in our project to do this.  Inspired by log4net renderers, I offer 
this simple patch.  It's working quite well for us.

Thanks for your work,
Drew

Original issue reported on code.google.com by drewburl...@gmail.com on 12 Feb 2011 at 5:29

Attachments:

GoogleCodeExporter commented 9 years ago
My previous message leaves much to the imagination.  I was in a rush to get 
home.  Here are more details.

This patch allows registration of a custom exception renderer with the 
following config entries:

<sectionGroup name="elmah">
  <section name="errorRenderer" type="Elmah.ErrorRendererSectionHandler, Elmah"/>
</seciontGroup>
<elmah>
  <errorRenderer type="Framework.SasErrorRenderer, Framework" />
</elmah>

We provided our own renderer that used an object renderer to recurse through 
and render the properties of an exception as well as the Data element, allowing 
us to add context to an object as it was bubbled up the stack.  This saves us 
from defining and throwing a slew of new exceptions just to capture context.  
We didn't want to lose that output when we added Elmah, so I added this patch.  
Hope you find it useful.

Original comment by drewburl...@gmail.com on 12 Feb 2011 at 6:46