Re: How to extract all exceptions for any method

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Apr 16, 7:12 am, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
On Tue, 15 Apr 2008 14:01:47 -0700, paul <p...@xxxxxxxxxx> wrote:
I am pretty sure this can be done as Visual Studio 2005 already tells
you the specific Exceptions that can be generated by a single method.

I'm not aware of any feature in VS that does this generally.  It's true  
that the documentation for much of .NET includes information as to which  
exceptions may be thrown, and inasmuch as VS shows you that documentation,  
it will show you those specific exceptions.

If you know of something more specific than that, perhaps you could  
provide more details regarding what you're seeing in VS.

Also Red-Gate Exception hunter validates your code and highlights all
possible exceptions (part from generic exception).

I'm not familiar with that tool.  However, it's plainly false that it  
"highlights all possible exceptions".  No doubt it does a good job  
traversing the call chain (something that's easily done via reflection),  
looking for code that creates and throws exceptions.  But it's simply not  
possible to find literally all possible exceptions.

As Marc already asked, was there some specific situation or scenario  
you're trying to address?  Generally speaking, if it's possible for a  
method to throw some exception that can be usefully dealt with, it will be  
documented by the author of that method.  Other kinds of exceptions that  
might be thrown wouldn't be relevant information anyway, by definition.

Pete

Hi

This is possible and it's standard in VS Studio 2005 (C#).

Hover your mouse over a method (e.g. System.IO.File.Open) and wait for
the little popup window, here lists all known exceptions (again part
from generic exceptions), so it is possible.

Paul
.



Relevant Pages

  • Re: CLOS and C++
    ... > relative percentage of needing to know the exceptions a given method can raise ... >> with the information provided by the mandatory type declarations. ... javadoc comments and put it into the class file and then change the ... attach the documentation directly to the elements its documenting so ...
    (comp.lang.lisp)
  • Re: SqlConnection.Open() Which ErrorCodes
    ... exceptions is that they are often too generic and the ... Hitchhiker's Guide to Visual Studio and SQL Server ... the documentation in the .NET Framework Help for these classes: ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problems Handling Errors Correctly
    ... But as with your observation about the .NET Framework itself, to some extent this is a consequence of the sheer size of the Framework. ... One hopes that over time, the documentation will get filled in, but it's not hard to see why some things may have been considered lower priority and receive a basic "template" documentation rather than a fully useful description. ... the docs include a section immediately after the "Return Value" section enumerating possible exceptions. ... If it's not the case, or it's incomplete, or it leaves out exceptions that could be thrown my methods called from the method, that would really be a drag. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie question: what exceptions are thrown by FTP class
    ... give which lists the thrown exceptions and the reasons why ... If the author includes that in the API documentation, ... determine from static source analysis which exceptions may or may not be ... the exception is thrown from nlst> retrlines> ...
    (comp.lang.ruby)
  • Re: a criticism of java
    ... > Am I to take this to mean that documentation needs to duplicate the ... I was really only referring to after the throws clause. ... appeared to me to not agree with unchecked exceptions, ... > is better expressed in the language. ...
    (comp.lang.java.programmer)