Home > Articles > Programming > .NET and Windows Programming

Framework Patterns: Exception Handling, Logging, and Tracing

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Exception handling is more than just throwing and catching objects in .NET. There are many design elements in providing a robust system, and providing a sound exception handling, logging, and tracing schema are among the first steps. In this chapter from .NET Patterns: Architecture, Design, and Process, you'll learn best practices for determining when to throw, catch, and ultimately log your errors.

One of the primary success factors for implementing a robust framework is providing enough information at runtime so that the system can be effectively monitored. Despite how good a programmer you think you are, there will always be bugs. Hopefully, by the time your application goes to production, most of these can be discovered. However, no matter how diligent you may be, problems still arise. Eventually, you will be faced with solving the issue as quickly and as painlessly as possible. The better your framework is built to handle both preproduction and postproduction problems, the faster they will be solved.

Information is key to solving any problem. The more accurate, abundant, and accessible the errata, the better. This is especially true in postproduction, when you may not have the liberty of being seated at the desktop of your users trying to solve their issues. I hope the topics in this chapter will provide you with some “best practices” that you can employ in any application, typically at the middle tier. I provide a melee of ideas, dos, and don'ts here to give you a few tips on which can be incorporated at any level. Unlike design patterns, these are not fixed to any one design but are more specific to the .NET framework. For those repeatable implementation steps, I've included a few implementation patterns that will add some benefit to any new or existing middle tier.

Like the remaining the chapters in this book, this chapter serves as a cookbook of ideas and does not have to be read in any particular order. The following topics will be covered in this chapter:

  • Exception Handling

  • Exception Logging

  • Exception Chaining

  • Building a Base Exception Class

  • Tracing and Trace Listening

  • Error and Call Stacks

  • When, Where, and How to Log

  • SOAP Exceptions and SOAP Faults

  • Interop Exception Handling

    The following implementation patterns will be described in detail:

  • Remote Tracer

  • Custom SOAP Exception Handler

  • System Exception Wrapper

  • SOAP Fault Builder

  • Share ThisShare This
  • Your Account

Discussions

Completley WRONG Advice in article regarding the use of the event log
Posted Nov 13, 2008 02:39 PM by jimmyzimms
0 Replies
Compelte Violation of SRP!
Posted Nov 13, 2008 02:36 PM by jimmyzimms
0 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jennifer  BortelWin FREE iPhone Developer Books and Videos- Introducing @InformIT Giveaways
By Jennifer Bortel on February 5, 2010 No Comments

Apples’s recent iPad announcement made our hearts flutter so we couldn’t resist making an announcement of our own!

Today marks the first ever @InformIT Giveaway!

We’ll regularly post a video like this one profiling spectacular prizes we’re giving away—from books and videos to T-shirts and other exciting stuff. Check out the video below to see the giveaways for today, and then scroll down for more prize details and instructions on how to win them!

Dustin Sullivan"Every OSX developer should have this book on their desk."
By Dustin Sullivan on February 1, 2010 No Comments

That was the sentence Mike Riley ended his recent Dr Dobb's CodeTalk review of Cocoa Programming Developer's Handbook with.

David ChisnallCocoa Tip of the Day, 1/29/10
By David Chisnall on January 29, 2010 No Comments

Don't ignore old versions of OS X.

See All Related Blogs

Informit Network