开发者

Is there an easy way to find out what exception types a class throws?

I am using the ReportServices Web Services API and I want to开发者_开发技巧 determine the exceptions that can be thrown by it.

Is there an easy way to do that?


C# does not have exception specifiers like Java does, so the primary way to determine what exceptions a method throws is to look at the documentation and hope that the developers documented the possible exceptions.

Assuming you're talking about the SQL Server Reporting Services Web Service, it looks like their online API reference does mention exceptions. For example, for CreateSchedule it says:

This method throws an rsUnsupportedParameterForModeException exception if a non-null value is specified for the SiteUrl parameter in Native mode.

Alternatively, if you have lots of time, you can use Reflector to dig through the implementation of the API methods you call (and the methods they call, and so on...) to see what gets thrown.


Keep in mind that exceptions can still be raised due to internal errors. You can look up the documentation and have a look at the exceptions manually raised, but some NullReference or OutOfMemory can still occur. Getting an complete list will be quite painful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜