[PATCH conductor 1/2] BZ821341: template_xml: show the same errors as CLI

mzatko at redhat.com mzatko at redhat.com
Wed Aug 8 15:03:11 UTC 2012


From: Maros Zatko <mzatko at redhat.com>

---
 src/app/controllers/images_controller.rb |    8 ++++----
 src/app/models/template_xml.rb           |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
index c3ca98c..af2bacc 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -234,8 +234,8 @@ class ImagesController < ApplicationController
 
     begin
       doc = TemplateXML.new(xml_source)
-    rescue Nokogiri::XML::SyntaxError
-      errors = [t('template_xml.errors.xml_parse_error')]
+    rescue Nokogiri::XML::SyntaxError => e
+      errors = [e.message]
     else
       doc.name = @name unless @name.blank?
       @name = doc.name
@@ -259,8 +259,8 @@ class ImagesController < ApplicationController
 
     begin
       doc = TemplateXML.new(@xml)
-    rescue Nokogiri::XML::SyntaxError
-      errors = [t('template_xml.errors.xml_parse_error')]
+    rescue Nokogiri::XML::SyntaxError => e
+      errors = [e.message]
     else
       @name = doc.name
       errors = doc.validate
diff --git a/src/app/models/template_xml.rb b/src/app/models/template_xml.rb
index 323b4e0..6462f36 100644
--- a/src/app/models/template_xml.rb
+++ b/src/app/models/template_xml.rb
@@ -38,8 +38,8 @@ class TemplateXML
   def self.validate(xmlstr)
     begin
       doc = TemplateXML.new(xmlstr)
-    rescue Nokogiri::XML::SyntaxError
-      return [I18n.t('template_xml.errors.xml_parse_error')]
+    rescue Nokogiri::XML::SyntaxError => e
+      return [e.message]
     end
     return doc.validate
   end
-- 
1.7.10.4




More information about the aeolus-devel mailing list