我实在不明白嵌套innerexception的用处,大家能给我介绍一下吗?
为什么要这样操作有什么好处?
还有它到底是被谁扑捉到了?事先怎么安排的呢?
try
catch(excetpin e){
throw new aaaexception('aaa',e){}
}aaaexception 在哪?肯定有吗?设计异常方面大家能不能说点建议啊
为什么要这样操作有什么好处?
还有它到底是被谁扑捉到了?事先怎么安排的呢?
try
catch(excetpin e){
throw new aaaexception('aaa',e){}
}aaaexception 在哪?肯定有吗?设计异常方面大家能不能说点建议啊
下面的内容来自http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspxWhen an exception X is thrown as a direct result of a previous exception Y, the InnerException property of X should contain a reference to Y. Use the InnerException property to obtain the set of exceptions that led to the current exception. You can create a new exception that catches an earlier exception. The code that handles the second exception can make use of the additional information from the earlier exception to handle the error more appropriately. Suppose that there is a function that reads a file and formats the data from that file. In this example, as the code tries to read the file, an IOException is thrown. The function catches the IOException and throws a FileNotFoundException. The IOException could be saved in the InnerException property of the FileNotFoundException, enabling the code that catches the FileNotFoundException to examine what causes the initial error. The InnerException property, which holds a reference to the inner exception, is set upon initialization of the exception object
我知道堆栈但不知道这个异常是怎么加到堆栈的呢?