deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/3] Core: Added one error view to handle all error states
Date Mon, 14 Jan 2013 12:15:14 GMT
From: Michal Fojtik <mfojtik@redhat.com>

This should fix the numerous problems we have with
maintaining large list of error views. The HAML views
for errors looks all the same, so this patch should
provide consistency across all reported errors.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/helpers/deltacloud_helper.rb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 4575ae2..c9dee05 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -18,6 +18,10 @@ module Deltacloud::Helpers
 
     require 'benchmark'
 
+    def current_provider
+      Thread.current[:provider] || ENV['API_PROVIDER'] || 'default'
+    end
+
     def collections_to_json(collections)
       r = {
         :version => settings.version,
@@ -124,16 +128,16 @@ module Deltacloud::Helpers
       end
 
       respond_to do |format|
-        format.xml {  haml :"errors/#{@code || @error.code}", :layout => false }
+        format.xml {  haml :"errors/common", :layout => false }
         format.json { JSON::dump({ :code => @code || @error.code, :message => message,
:error => @error.class.name }) }
         format.html {
           begin
-            haml :"errors/#{@code || @error.code}", :layout => :error
+            haml :"errors/common", :layout => :error
           rescue RuntimeError
             # If the HTML representation of error is missing, then try to report
             # it through XML
             @media_type=:xml
-            haml :"errors/#{@code || @error.code}", :layout => false
+            haml :"errors/common", :layout => false
           end
         }
       end
-- 
1.8.0.2


Mime
View raw message