我目前正在编写一个小框架,将供公司内的其他开发人员在内部使用.
我想提供良好的Intellisense信息,但我不确定是否有how个可以记录抛出的异常.
在以下示例中:
public void MyMethod1()
{
MyMethod2();
// also may throw InvalidOperationException
}
public void MyMethod2()
{
System.IO.File.Open(somepath...); // this may throw FileNotFoundException
// also may throw DivideByZeroException
}
我知道记录异常的标记是:
/// <exception cref="SomeException">when things go wrong.</exception>
我不明白的是如何记录代码called by MyMethod1()
引发的异常?
- 我是否应该记录由
MyMethod2()
引发的异常 - 我应该记录
File.Open()
抛出的异常吗?
记录可能的异常的最佳方式是什么?