Thursday, February 24, 2005

Finally got around to some C#'ing :-)
In order to generate the massive amount of reports I'm writing a multi-process, multi-threaded report generator.

Experimenting with the Enterprise Library (Patterns & Practices) which has some very nice features. The configuration tool is very handy and lets you visually configure the framework properties. Creating an Exception handler with logging is a matter of minutes.

To use it just create a reference to the DLL. Policies can be defined per exception and how to handle it.

int a = 10;
int b = 0;
int c = a / b;

catch(Exception ex)
bool rethrow = ExceptionPolicy.HandleException(ex, "General Policy");
if (rethrow)
throw ex;

The policy provides a couple of handlers:
  • Custom handler: you create your own handler class
  • Logging handler: logging to text file, eventlog, ...
  • Replace handler: replace an exception with a new one, for example to remove sensitive data from exception information
  • Wrap handler: to wrap an exception in another exception (InnerException), for example to pass exceptions from your data layer to your business layer which then handles the exception

I hope more posts will follow about the Enterprise Library!

No comments: