Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see list of possible exception in some Class.(C#.NET)

I have a lot of classes that have been written in C#.NET, and I need to know what exceptions can be thrown by them. How I can do it in Visual Studio 2005.

like image 456
Sergii Avatar asked Oct 29 '10 10:10

Sergii


2 Answers

You pretty much can't. Firstly, .NET/C# don't have checked-exceptions like Java, and secondly there are a number of general exceptions that could happen for any freaky reason.

On a method-by-method basis, you can decorate methods with the exceptions they raise, but this is not guaranteed to be present, accurate or complete.

In general, though, any unexpected* exception should be treated as terminal; just unwind, cleaning up (using) etc as you go and propagate the exception - or at least log it if the operation isn't critical.


*=I'll leave aside the philosophical discussion of whether an exception should every truly be expected as such...

like image 87
Marc Gravell Avatar answered Sep 28 '22 18:09

Marc Gravell


You have to look at the code, it is the only source for this.
It is possible to specify what exceptions can be thrown in xml comments but it is not mandatory, so often this imformation is missing.

like image 24
Andrew Bezzub Avatar answered Sep 28 '22 17:09

Andrew Bezzub