如果我有一个使用语义版本控制管理的公共 API,是否应该将方法可能引发的异常类型的更改视为重大更改?
考虑这个例子:
// API version 1.0.0
public void Method()
{
// this may throw ThirdPartyComponentException
_thirdPartyComponent.SomeMethod();
}
调用代码可能如下所示:
try
{
_api.Method();
}
catch (ThirdPartyComponentException e)
{
//some recovery logic
}
如果 的实现API.Method
因此改变:
// API version ?.?.?
public void Method()
{
try
{
// this may throw ThirdPartyComponentException
_thirdPartyComponent.SomeMethod();
}
catch (ThirdPartyComponentException e)
{
throw new MyApiException(e);
}
}
是否应该增加语义版本的主要值,因为这种变化可能会破坏?它肯定会破坏上面的异常处理程序,所以看起来像是一个重大变化。