chris carter's web log

Home |  Contact |  Admin
 

Evil Exception Handling

Posted on October 29, 2008

Grrrrrrrrrrrrrrr..........here's what I started this morning with(click to enlarge):

Can anyone spot the exception? the real exception?

Ya, me neither, I have no clue what happened because of these lines:

After commenting out the exception squishing code above and rebuilding, here are the images of the results I see now(I cut the screen shot into two because it was too big for one). 

Now can you spot the actual problem?

The problem was simple, my local copy of the database for this app is out of date, I just need to update. But to figure this out I had to crack open the solution, comment out lines of code that added zero value(actually reduced value), rebuild and then see the issue. Frustrating.

Comments

Mike

Why not enable logging? Both NH and AR are very verbose.

Chris

@Mike: I could enable logging, but that would only help me diagnose an issue with my usage of NH or AR, but there was no issue with either of those.

The problem here was just that my schema was outta sync, and the other dev hid that information from me by throwing an exception with less info than the original exception contained. 

The stack trace in the real exception above even contained the sql that NH was trying to execute, plenty of info from that aspect to figure out the problem; however that's not always the case, so yes, logging and/or sql profiler can pick up that slack.

Jason Bock

I just did a presentation at the Twin Cities Code Camp, talking about exception handling. One of the points was the same example you just showed: catching AND throwing the Exception type. Ugh.

But thanks for posting this, I plan on adding this entry into my references paper for my talk :).

Post a Comment

(required)
(required)
(no HTML!)