.net structure exception handle

.net exceptions are divided into two diifferent kinds.

1.system exceptions: inherited from System.SystemException, such as ArgumentOutofRangeException,IndexOutOfRangeException,StackOverflowException. system excepions are exception which triggled by .net framwork.

2. application exceptions: inherited from System.ApplicationException which inherite from System.Exception.

 

key words in .net exceptions: throw, try,catch, finally

 

menbers in system.exception

1. Data:(read/write) return a key/value pair which inherite from IDictionary, can include more programmer defined information in it.

2. HelpLink(read/write): return a URL which can help user to find out how to solve this exception

3. InnerException(read):

4. Message: (read) return a value which show error messages about this exception(can defined in constructor of an exception).

5. Source:(read/write) return the assembly's name of the exception

6. StactTrace: (read)

7. TragetSite: (read) return a MethodBase type,describe the details of the expection method.

 

example;

 

public class CarIsDeadException: ApplicationException

{

  public CarIsDeadException(){}

  public CarIsDeadException(string message) : base(message){}

  public CarIsDeadException(string message, System.Exception inner): base(message, inner){}

  protect CarIsDeadException(System.Runtime.Serization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context):base(info,context){}

  //other user defined propertied, attribute, method;

}

posted @ 2010-11-08 14:46  growing pain  阅读(282)  评论(0编辑  收藏  举报