[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

.Net exception for System.Net.WebClient

I want to test if my codes can catch as many possible exception as it can in try-catch block.
In order to do that, I need to know what is the list of exceptions can be raised by using a particular class.
For example, when I use System.Net.Webclient, what exceptions can be raised? in MSDN, I can find any list of possible exceptions for a specific class I use.
In more specific, when I create an object system.net.webclient, what excpetions are thrown with the constructor?
And when I use methods of the class, what exceptions are thrown?
How do I know what list of exceptions can be thrown for constructor and methods?
0
crcsupport
Asked:
crcsupport
1 Solution
 
Fernando SotoCommented:
Hi crcsupport;

Microsoft documents each exception that can be thrown by methods of a class. To see these exceptions goto the documentation and see the section in the method called Exceptions. For example if you what to know what exceptions the function WebClient.OpenRead(Uri) goto your browser and make a search on, WebClient.OpenRead .Net MSDN, note that I placed .Net MSDN at the end, I found out by doing this what I am looking for on the Microsoft site always is shown first or within the first couple of lines. So when I placed WebClient.OpenRead .Net MSDN in Google search bar in the result it was the second on the list. When I followed the link I looked for the section on Exceptions and found that it is programed to throw two types of exceptions, ArgumentNullException and WebException. Now that does not mean that while that methods is being executed it will not throw some other types of exception which is from the code that you have placed there so you need to be aware of what other exception can be thrown from that code by looking it up as well.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now