From 48c1d8c341e1fe09111424131f7d223ad032b7e1 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 28 Mar 2010 23:21:19 -0700 Subject: Provide a better error if the parsed REXML document has no root [#3803 state:resolved] --- activesupport/lib/active_support/xml_mini/rexml.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb index 3db48ce5a3..863d66a91d 100644 --- a/activesupport/lib/active_support/xml_mini/rexml.rb +++ b/activesupport/lib/active_support/xml_mini/rexml.rb @@ -27,7 +27,13 @@ module ActiveSupport data.ungetc(char) silence_warnings { require 'rexml/document' } unless defined?(REXML::Document) doc = REXML::Document.new(data) - merge_element!({}, doc.root) + + if doc.root + merge_element!({}, doc.root) + else + raise REXML::ParseException, + "The document #{doc.to_s.inspect} does not have a valid root" + end end end -- cgit v1.2.3