How can I find exception names (in intellisense) available to run VS2008

One thing that I find very frustrating with C # is when I find some kind of problem and I want to throw a significant exception. I find it very difficult to find these exceptions in intellisense. There is no Exception namespace, so I cannot list all exceptions through intellisense without delving into an exception search.

I'm not trying to create my own exceptions, I'm just trying to figure out if there are other options besides searching googling for an exception to find its namespace so that I can use it.

+4
source share
3 answers

You can view the entire tree of exception classes in the object browser. Find System.Exception and then click the derived types. not 100% sure that they are all there, but most of them are for sure. System.Exception -> Derived types (also in the root of the System.Excecption tree)

+2
source

For the most part this is bad practice. There are a small number of exceptions that you must reuse (InvalidOperation, NullReference, ArgumentException, several others). But you should not, for example, throw SqlException yourself, because you do not know what the infrastructure can do with it.

Creating your own exception hierarchy adds value to your application at times of error. Reusing exceptions that have already understood the meaning leads to confusion - a loss of meaning.

+6
source

You can find some exceptions on MSDN, here . In general, these are exceptions that you will ever throw, and in many cases you will receive your own exceptions to these exceptions. However, one method that throws too many different exceptions is usually not approved. Also, remind the documentation tag <exception> xml. Using this tag has a long way to educate users who exclude your method, and when. Probably more important, in terms of clarity, than throwing exceptions from certain classes.

+1
source

All Articles