.net structure exception handle

原文链接: http://www.cnblogs.com/huangwj21/archive/2010/11/08/1871756.html

.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;

}

转载于:https://www.cnblogs.com/huangwj21/archive/2010/11/08/1871756.html

猜你喜欢

转载自blog.csdn.net/weixin_30556959/article/details/94963593
今日推荐