views:

36

answers:

1

Is there a way in VS2008 IDE for c# to see all the possible exception types that can possibly originate from a method call or even for an entire try-catch block?

I know that intellisense or the object browser tells me this method can throw these types of exceptions but is there another way than using the object browser everytime? Something more accessible when coding? Furthermore, I don't think intellisense or the object browser do anything more than read the XML code comments.

Shouldn't it be possible to scan a class's source and find all the exception types that can be thrown. (Forget path-ing based on method input, just scan the code for exception types)

Am I wrong? Extending this idea, you should be able to hover over the 'try' or 'catch' keywords and present a tooltip with all the types of exceptions that can be thrown.

My question boils down to, does a VS2008 add on like this exist? Does VS2010 do this perhaps? If not, could you implement it the way I've described, by scanning the class code for thrown exception types and would people find it useful. Exceptions bubble up so you have to scan every bit of code every method call, which I guess could be impractical, though I suppose you could build an index the first time and increase your speed that way.

(It might be a cool little project....)

+4  A: 

What you're looking for is Red-Gate Exception Hunter.

However, Exception Hunter is a static analysis tool, and there's no way it will be able to tell you everything for every piece of code there is.

For instance, given the prevalence of IoC containers today, what kind of exceptions would you expect the following lines to be able to throw:

var service = IoC.Resolve<ILogger>();
service.Log("Here");

It depends entirely on the actual type of logger being resolved, does it log to a file? to a database? to a network service? to the event log?

Lasse V. Karlsen
That looks pretty sweet. If only I coded in a .NET language. :)
dash-tom-bang