Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Does Visual Studio 2008 have a tool to show which Exceptions could be raised by a piece of code?

For example, if I'm opening a file, I know a FileNotFoundException might happen, or if I'm converting a String to double, a FormatException may happen. Obviously, if a method does both, both can be raised.

Is there a way to quickly see all possible exceptions raised by a method though? Keeping track of it myself seems error prone.

like image 284
zxcvbnm Avatar asked Sep 09 '25 22:09

zxcvbnm


2 Answers

It's not built into VS. There are 3rd party tools, though, like Redgate's exception hunter.

Edit I'm not employed by RG, but I am a fan of their products. I've tried this particular one, but we ended up not buying it.

like image 198
taylonr Avatar answered Sep 12 '25 13:09

taylonr


If memory serves me correctly if the intellisense tool tip should have a list of exceptions the method can throw. You can also open a browser tab in visual studio pointing to MSDN like so: http://msdn.microsoft.com/en-us/library/b9skfh7s.aspx#ddueExceptionsToggle

like image 37
Christopher Tarquini Avatar answered Sep 12 '25 14:09

Christopher Tarquini