Documentation (http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/
Parser.html#M000123, bottom of the page) says that
XML::Parser::ParseError should be thrown. I tried to raise it (trying
to parse bad xml-string) and the exception is really different:
irb(main):005:0> XML::Parser.string( "<foo></ba/r/></foo>").parse
Fatal error: expected '>' at :1.
Fatal error: Opening and ending tag mismatch: foo line 1 and ba
at :1.
Fatal error: Extra content at the end of the document at :1.
LibXML::XML::Error: Fatal error: Extra content at the end of the
document at :1.
from (irb):5:in `parse'
from (irb):5
from (null):0
I think, i should handle LibXML::XML::Error instead. The problem is
solved.
On Sep 4, 6:18 pm, adrianopol <[email protected]> wrote:
> OK, so, how should I handle this exception?
>
> On Sep 4, 6:12 pm, Frederick Cheung <[email protected]>
> wrote:
>
> > On Sep 4, 2:41 pm, adrianopol <[email protected]> wrote:
>
> > > read_xml.rb:40:in `load_tasks': uninitialized constant
> > > LibXML::XML::Parser::ParseError (NameError)
> > > from read_xml.rb:71
>
> > > Question: why does ruby interpret XML::Parser::ParseError in rescue-
> > > clause as LibXML::XML::Parser::ParseError?
>
> > because the top level constant XML is LibXML::XML (check their
> > object_id )
>
> > Fred
>
> > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---