Commits

Cédric Bonhomme committed adb9932

Error messages are displayed with a dedicated function.

  • Participants
  • Parent commits b9ec373

Comments (0)

Files changed (1)

File source/pyAggr3g470r.py

         try:
             self.mongo.update_feed(feed_id, {"site_link":new_site_url})
             tmpl = lookup.get_template("confirmation.html")
-            message = "<p>The URL of the site has been changed.</p>"
+            return tmpl.render(message="<p>The URL of the site has been changed.</p>")
         except:
-            tmpl = lookup.get_template("error.html")
-            message = "<p>Error when changing the URL of the site.</p>"
-        finally:
-            return tmpl.render(message=message)
+            return self.error("<p>Error when changing the URL of the site.</p>")
 
     change_site_url.exposed = True
 
         result = utils.change_feed_url(old_feed_url, new_feed_url)
         if result:
             tmpl = lookup.get_template("confirmation.html")
-            message = "<p>The URL of the feed has been changed.</p>"
+            return tmpl.render("<p>The URL of the feed has been changed.</p>")
         else:
-            tmpl = lookup.get_template("error.html")
-            message = "<p>Error when changing the URL of the feed.</p>"
-        return tmpl.render(message=message)
+            return self.error("<p>Error when changing the URL of the feed.</p>")
 
     change_feed_url.exposed = True
 
         try:
             self.mongo.update_feed(feed_id, {"feed_title":new_feed_name})
             tmpl = lookup.get_template("confirmation.html")
-            message = "<p>The name of the feed has been changed.</p>"
+            return tmpl.render("<p>The name of the feed has been changed.</p>")
         except:
-            tmpl = lookup.get_template("error.html")
-            message = "<p>Error when changing the name of the feed.</p>"
-        return tmpl.render(message=message)
+            return self.error("<p>Error when changing the name of the feed.</p>")
 
     change_feed_name.exposed = True
 
         try:
             self.mongo.update_feed(feed_id, {"feed_image":new_feed_logo})
             tmpl = lookup.get_template("confirmation.html")
-            message = "<p>The logo of the feed has been changed.</p>"
+            return tmpl.render("<p>The logo of the feed has been changed.</p>")
         except:
-            tmpl = lookup.get_template("error.html")
-            message = "<p>Error when changing the logo of the feed.</p>"
-        return tmpl.render(message=message)
+            return self.error("<p>Error when changing the logo of the feed.</p>")
 
     change_feed_logo.exposed = True