Saturday, January 1, 2011

Use ApplicationException when creating your own custom exceptions

In March of 2009 I talked about Catch (Exception e): Right or wrong?. Since that time I've gotten into the habit of also deriving my custom application exceptions from the .NET ApplicationException rather than just Exception. This .NET class serves to help identify exceptions that are specific to an application, hence the name.

To make things really easy for us to create application-specific exceptions, use the Visual Studio 2010 code snippet, "exception". Be sure to use the tab key to update the base class to ApplicationException. The snippet contains all the code to adhere to the exception derivation best practices.

Very handy!

No comments:

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...