Geeks With Blogs
Greg Young Greg.ToString()

Is feedback broken?

I have been trying to leave feedback for a few people but it has been failing.

 

 

I have requested a new sourceforge space which should be available by the end of the week. I will be placing my exception management library up, I will place a link there. You are probably thinking to yourself “Wait isn't there a MS application block for that?”. Well I found the application block a small step above useless for my applications as it is fairly difficult to manage and the configuration application block is not in usage in any of the systems thus it produces a a dependency I would prefer to avoid.

So what's different with it?

The way it works is based upon an object graph which defines its configuration (conveniently enough there is built in support for putting this object graph xml serialized in a file or in your app.config as a section but it can come from anywhere i.e. db webservice etc). The configuration basically can be broken down into three areas.

1) Publishing mechanism plugins : These plugins are used to physically publish information there are a few included with the package to show how to implement a plugin, they are in their own assembly to limit the number of dependencies on the library itself. The mechanisms included are

Trace : Writes to Trace

Console : Writes to Console

Email : Sends an email to an arbitrary person with an arbitrary subject etc

Event Log : Sends it to a machine/event log source

File : outputs it to a file

2) Formatting plugins : These plugins are used to format an exception into a usable format

I have a few of these I may put up but the most useful one I have is based heavily on reflections allowing you to substitute object fields into your text dynamically, I also have an xslt transformation plugin which can be relatively useful.

3) Mapping for exceptions, maps N sets of a formatting plugin and a publishing plugin

The mapping engine is the intresting part, it can work in a very similar fashion to the application block where I define plugins to map to a given exception type but it also has some additional mapping options. The major mapping option is the ability to use object's parent types in order to define a mapping which allows us to define a hierarchy of exceptions. Take the example of ...

System.Exception

       MyNamespace.MyBaseException

                 MyNamespace.MyBaseSqlException

                              MyNamespace.NoRecordsUpdatedException

 

In my definition file I can define a mapping on System.Exception, this will apply to System.Exception and all types derived from System.Exception (which should be all cases). I can therefore create special publishing rules to MyBaseException which will only apply to exceptions which are within my own framework as opposed to framework exceptions. Since this mechanism also lets me specify my custom formatters I could do something along the lines of creating a special exception class

 

public class MyBaseSqlException : MyBaseException {

      private string m_SqlText;

      public string SqlText { get { return m_SqlText; } }

     //etc

}

Then create a specialized formatter that knows how to format any exception derived from MyBaseSqlException (in particular the usage of the “SqlTextField”. I could then set only my sql exceptions with this specialized formatting to automatically email directly to my db administrator by simply placing the definition on MyBaseSqlException. If I were to create a new custom Sql exception a  year from now it would implicitly receive the same behavior.

This code is by no means a new or wonderfully original thought but it is tested and works very well ( and has full documentation associated with it:) )

 

 

Posted on Thursday, December 1, 2005 1:06 AM | Back to top


Comments on this post: Feedback & Exception Management

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Greg Young | Powered by: GeeksWithBlogs.net