Unexpected Exceptions

R

rickbear

Hi Group,
I am using StreamReader in a program I develop.
In the MSDN it says the constructor can throw these exceptions:

ArgumentException
ArgumentNullException
FileNotFoundException
DirectoryNotFoundException
IOException

But when when doing this:
StreamReader someReader = new StreamReader("\\");

I get an "UnauthorizedAccessException".
I know the above example is useless, but I stumbled over it by
accident. My question is more in general:
Why isn't that noticed in the MSDN? And how can I be sure to catch all
expected exceptions if I will not catch the super exception
"Exception"?

- rick -
 
R

rickbear

[...]
Why isn't that noticed in the MSDN? And how can I be sure to catch all
expected exceptions if I will not catch the super exception
"Exception"?

I think that the general answer to that is "you can't".

[...]

Hi Pete,
Thanks for your fine answer.
- rick -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top