Solved

.Net exception for System.Net.WebClient

Posted on 2013-11-29
1
597 Views
Last Modified: 2013-11-29
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
Comment
Question by:crcsupport
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39685964
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question