.NET Zone is brought to you in partnership with:

I am developer and technology maniac who is working on Microsoft and PHP technologies. I have ASP.NET MVP title and I hold MCAD, MCSD and MCTS certificates. When I have free time I usually play with new technologies, hack something, read books, participate in communities and speak in events. I am also active blogger and my ASP.NET blog is the place you can find some interesting reading about my discoveries and personal thoughts. Gunnar is a DZone MVB and is not an employee of DZone and has posted 140 posts at DZone. You can read more from them at their website. View Full User Profile

Understanding Exceptions - The Artistic Way

05.29.2013
| 2058 views |
  • submit to reddit

Finding out reason of bug in code is not always easy thing to do. But it can be extremely hard if you have no idea what do with information that exceptions provide you. In this posting I introduce you weird artistic handling of exceptions and unfortunately this story comes from real life.

Years ago I had honor to witness one debugging session where one lengthy method threw NullReferenceException. It was actually one SharePoint form or web part that threw exception and the exption message was shown to user. The developer who worked on debugging this form or web part had also stack trace available for exception. One more thing to mention – two years of experience on .NET and university degree in software development were also written to CV of this guy.

Let’s start. NullReferenceException means that code is trying to use some object that is null. When attaching debugger to process then it is easy to step through problematic method and find out where exception occurs.

But what I saw was something new to me – the guy was just watching the message and then looking at different parts of source code to find out where things can go wrong. No, he was not investigating this one method but whole code in solution. Why is he doing something like this and why takes solving of this problem more time than half of day?

Well, here is how exception can be understood:

Exception - important and technical information
This is just arbitrary exception I stole somewhere from web.

  • important information – this is the information that gives us details about bug and based on this information all debugging can be done,
  • technical information – is… well… just techinal information like you can see when operating system crashes or ATM goes mad or your tablet has hardware fault – it is there, it is important but it’s just this technical information like all technical information everywhere else (maybe somebody needs it some day).

Of course, after short lecture about exceptions the problem got solved with ten minutes but the memory remains…

Related Posts

The post Understanding exceptions artistic way appeared first on Gunnar Peipman - Programming Blog.

Published at DZone with permission of Gunnar Peipman, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)