❔ I have an API function and I want to know what exception it can throw. How can I do that?
This is not said in the documentation
3 Replies
What's an "API function"?
Just a method?
Other than digging through the source code of the method, there's no way to know what kinda of exceptions it can throw. If you know a method can commonly throw exceptions but you don't know what kind of exceptions and want to be safe, then just do a standard try/catch around it.
If you're using a modern IDE, you can mouseover the functions name and see what the tooltip states. Properly maintained APIs will use XML docs to list exceptions they might throw, but if they are calling even more functions internally that can throw exceptions, those might not always be listed.
I'd use the XML docs as a reference but keep in mind more might happen. YMMV.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.