Every Exception Has A Unique GUID

If you know me you will know that I love GUIDs and use them for everything.  One of the things I use them for is to create a unique identifier to error messages in my code.  I have override the Exception class adding my own method that looks like this:


public ProviderException(System.Guid error, string message, Exception innerException)
    : base(String.Format(CultureInfo.CurrentCulture, "{{{0}}}: {1}", error.ToString(), message, innerException))


Basically, anytime that I want to throw an exception in my code, I do so with a unique GUID.  The calling code looks like this:


catch(SoapException soapException)

    throw (new ProviderException(new Guid("{513EEF48-8C02-4135-9344-2A401EAF2112}"), soapException.Message, soapException));



I have the option of creating my own message, and I always pass the exception I am trapping as the inner exception.  Notice that I have a hard coded GUID in my code.  It is not Guid.NewGuid() – since this would create a different GUID every time the error happened.  What I want is a unqiue identifier to the error line in the code.


My client application catches all the errors and presents the user with this dialog:




Notice the more information link at the bottom of the dialog.  If the user’s click on this link a browser window is open to:




Which is an ASP.NET MVC page with more information about this issue and a forum for user discussion.  This allows my company to update the error information without having the user upgrade their installed application.  It also allows us to post solutions on the web site.


The user can also do a search for the error message using the GUID and see everyone else that has blogged, commented, or complained about the error.


Notice also that I might not know all the errors that will happen in my application or how often, however I can get statistics on how many times the error information is requested from the web site, focusing my bug fixing efforts for the next revision.




Popular posts from this blog

Yet once more into the breech (of altered programming logic)

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

How to convert SVG data to a Png Image file Using InkScape