lib/xamplr/from-xml.rb in xamplr-1.9.0 vs lib/xamplr/from-xml.rb in xamplr-1.9.1

- old
+ new

@@ -90,14 +90,12 @@ def parse(filename, tokenise_content=true, is_realising=false) begin setup_parse(filename, tokenise_content, is_realising) element, ignore = parse_element return element - rescue Exception => e - puts "trouble parsing file: '#{filename}'" - puts "Exception: #{e}" - raise + rescue => e + raise RuntimeError, "trouble parsing file: '#{filename}' -- #{ e }", e.backtrace end end def realise_string(string, tokenise_content=true, target=nil) return parse_string(string, tokenise_content, true, target) @@ -106,14 +104,12 @@ def parse_string(string, tokenise_content=true, is_realising=false, target=nil) begin setup_parse_string(string, tokenise_content, is_realising) element, ignore = parse_element(nil, target) return element - rescue Exception => e - puts "trouble parsing string: '#{string}'" - puts "Exception: #{e}" - raise + rescue => e + raise RuntimeError, "trouble parsing string: '#{string}' -- #{ e }", e.backtrace end end def FromXML.tokenise_string(str, strip=true) return nil unless str @@ -138,10 +134,13 @@ if ((nil != namespace) and (0 < namespace.size)) then klass_name = "{#{namespace}}#{name}" klasses = FromXML.registered(klass_name) if (0 == klasses.size) then + # The class has not been registered (either it was never generated, or it was never loaded) +# puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] @@by_ns_tag: #{ @@by_ns_tag.inspect }" +# puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] @@by_tag: #{ @@by_tag.inspect }" xml_text = XMLText.new xml_text.build(self) xml_text = parent.note_adding_text_content(xml_text, @is_realising) parent.add_content(xml_text, @tokenise_content) if xml_text return xml_text, false @@ -261,12 +260,14 @@ when XamplObject then child = child.note_add_to_parent(element, @is_realising) if child child = element.note_add_child(child, @is_realising) if element child.append_to(element) if element and child when XMLText then + #TODO -- get rid of this puts puts "UNRECOGNISED Well-formed XML: #{child.to_s[0..25]}..." else + #TODO -- get rid of this puts puts "WHAT IS THIS??? #{child.class.name}" end end when LibXML::XML::Reader::TYPE_END_ELEMENT element = element.note_closed(@is_realising) @@ -356,14 +357,14 @@ @faking_an_end_element = false #describe_current_element_type #TODO -- get rid of this, it is for debugging only +#TODO -- really? begin okay = @reader.read rescue => e - puts "WHAT???? #{ e }" - raise e + raise RuntimeError, "WHAT?? -- #{ e }", e.backtrace end @just_opened_an_element = start_element? @insert_end_element = (@just_opened_an_element and @reader.empty_element?)