Solved

.Net exception for System.Net.WebClient

Posted on 2013-11-29
1
598 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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