Home > .Net CLR > Custom Exception

Custom Exception

When you develop a n-tier application, it is quite common to create a custom exception class to inform the upper level application layers from an error.

The followings are the list of the important (in my opinion) things to be  considered for creating such a class. 

public class NewException : BaseException, ISerializable
{
    public NewException()
    {
        // Add implementation.
    }
    public NewException(string message)
    {
        // Add implementation.
    }
    public NewException(string message, Exception inner)
    {
        // Add implementation.
    }

    // This constructor is needed for serialization.
   protected NewException(SerializationInfo info, StreamingContext context)
   {
        // Add implementation.
   }
}

References: 

  1. Designing Custom Exceptions: 
    http://msdn.microsoft.com/en-us/library/ms229064.aspx
  2. Design Guidelines for Exceptions
    http://msdn.microsoft.com/en-us/library/ms229014.aspx

					
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: