Can I automatically throw descriptive exceptions with parameter values and class feild information?
Posted
by Robert H.
on Stack Overflow
See other posts from Stack Overflow
or by Robert H.
Published on 2010-04-21T18:36:49Z
Indexed on
2010/04/21
19:53 UTC
Read the original article
Hit count: 312
I honestly don't throw exceptions often. I catch them even less, ironically. I currently work in shop where we let them bubble up to avicode. For whatever reason, however, avicode isn't configured to capture some of the critical bits I need when these exceptions come bouncing back to my attention. Specifically, I'd like to see the parameter values and the class’s field data at the time of the exception.
I’d guess with the large suite of .Net services that I could create a static method to crawl up the stack, gather these bits and store them in a string that I could stick in my exception message. I really don't are how long such a method would take to execute as performance is no longer a concern when I hit one of these scenarios.
If it's possible, I'm sure someone has done it. If that's the case, I'm having a hard time finding it. I think any search containing "exception" brings back too many resutls.
Anyway, can this be done? If so, some examples or links would be great.
Thanks in advance for your time, Robert
© Stack Overflow or respective owner