Windows Live Writer Plugin – PluginDiagnostics

Following on from my previous post on debugging, the API has a class called PluginDiagnostics.

This has got a series of methods for displaying and logging error messages from within your plugin.

In this post, I am going to use it to display an error to the end user and log the error message.

The method PluginDiagnostics.DisplayError displays an error message. PluginDiagnostics.LogError will log the error message. 

The log file location on Vista is %LOCALAPPDATA%Windows Live Writer,  while on XP is it %USERPROFILE%Local SettingsApplication DataWindows Live Writer.

Below is some sample code which displays and logs the error.

public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
{
    content = “Test PluginDiagnostics”;
    string errorTitle = “Error has occured: Code = 129453ABC”;
    string errorMessage = “Sorry but this plugin doesn’t work correctly. Report @ Blog.BenHall.me.uk”;
    PluginDiagnostics.DisplayError(errorTitle, errorMessage);
    PluginDiagnostics.LogError(errorMessage);

    return DialogResult.OK;
}

The error message displayed by the method looks like this:

image 

The contents of the log file would be this:

WindowsLiveWriter,1.1444,None,00004,23-Sep-2007 11:36:22.202,”Error has occured: Code = 129453ABC: Sorry but this plugin doesn’t work correctly. Report @ Blog.BenHall.me.uk”,””
WindowsLiveWriter,1.1444,None,00005,23-Sep-2007 11:36:22.237,”DisplayableException occurred: WindowsLive.Writer.CoreServices.DisplayableException: Error has occured: Code = 129453ABC – Sorry but this plugin doesn’t work correctly. Report @ Blog.BenHall.me.uk”,””
WindowsLiveWriter,1.1444,None,00006,23-Sep-2007 11:36:23.491,”Sorry but this plugin doesn’t work correctly. Report @ Blog.BenHall.me.uk”,””

Very useful class, plus the error message keeps it in the style of live writer for a consistent end user experience.

Technorati tags:

One thought on “Windows Live Writer Plugin – PluginDiagnostics”

Leave a Reply

Your email address will not be published. Required fields are marked *