Exception handling - how to know which exceptions are thrown 
Author Message
 Exception handling - how to know which exceptions are thrown

hey folks,

How do I know which exceptions may be thrown when invoking some method? .NET
docs lack this kind of info...as an example the method Load() from
XmlDocument class does not says anything about what happens when the
"contract rules" are broken!

Where should I look for such info?



Sat, 20 Dec 2003 03:44:32 GMT  
 Exception handling - how to know which exceptions are thrown
Henrique,

Quote:
>How do I know which exceptions may be thrown when invoking some method? .NET
>docs lack this kind of info...as an example the method Load() from
>XmlDocument class does not says anything about what happens when the
>"contract rules" are broken!

I don't know which version of the framework you're using, but the Beta
2 docs does indeed include the information you're looking for. An
XmlExcepion will be thrown. See

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemXmlXmlD...

Mattias

====================================

http://www.msjogren.net/dotnet/

CodeHound - The Software Developer's Search Engine
http://www.codehound.com



Sat, 20 Dec 2003 04:00:37 GMT  
 Exception handling - how to know which exceptions are thrown
The docs are actually fairly complete when it comes to
exceptions. In the example you are giving, if you mean
validating against a schema or DTD, then load doesn't do
this. All load does is load the document into memory,
making sure it is well formed xml. If it isn't then it
raises XmlException. If you want to validate the document
against a schema, then you will need to use the
XmlValidatingReader class.

Quote:
>-----Original Message-----
>hey folks,

>How do I know which exceptions may be thrown when

invoking some method? .NET
Quote:
>docs lack this kind of info...as an example the method
Load() from
>XmlDocument class does not says anything about what
happens when the
>"contract rules" are broken!

>Where should I look for such info?

>.



Sat, 20 Dec 2003 04:12:32 GMT  
 Exception handling - how to know which exceptions are thrown
In the help files there should be a list of possible exceptions that may
occur for each particular method. For instance, if you look under the first
overload for XmlDocument.Load it lists only XmlException as a possible
exception:

      XmlException  There is a load or parse error in the XML. In this case,
the document remains empty.

From this XmlException object that is thrown you have attributes available
to help track down the specific error (ie Contact Rules):
XmlException.LineNumber, XmlException.LinePostition, XmlException.Message
etc.......

Hope this helps,

Donny Mack


Quote:
> hey folks,

> How do I know which exceptions may be thrown when invoking some method?
.NET
> docs lack this kind of info...as an example the method Load() from
> XmlDocument class does not says anything about what happens when the
> "contract rules" are broken!

> Where should I look for such info?



Sat, 20 Dec 2003 04:35:54 GMT  
 Exception handling - how to know which exceptions are thrown
thanks a lot for your feedback!

The strange thing here is that my XmlDocument.Load help page does not says
anything about exceptions thrown....I ll check it again (I have VS
beta2)...


Quote:
> hey folks,

> How do I know which exceptions may be thrown when invoking some method?
.NET
> docs lack this kind of info...as an example the method Load() from
> XmlDocument class does not says anything about what happens when the
> "contract rules" are broken!

> Where should I look for such info?



Sat, 20 Dec 2003 05:05:16 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Handling exception thrown during initialization of global object?

2. Constructors that throw Exceptions - How to handle.

3. Crash In Exception Filter in Structured Exception HAndling

4. Floating Point Exceptions: MFC or Structured Exception Handling?

5. Exceptions : Combining C++ and Structured Exception Handling ?

6. property throws Exception in visual designer!

7. Throwing Exceptions in Constructors

8. System.Drawing.SafeNativeMethods threw an exception

9. std::list.clear() throws exceptions in .NET 2003.

10. Function that only throws an exception

11. too many controls throw exception

12. OK to throw exception from constructor?

 

 
Powered by phpBB® Forum Software