You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/05/03 16:33:37 UTC

svn commit: r1099077 - in /incubator/deltacloud/trunk/server: lib/deltacloud/helpers/ public/stylesheets/compiled/ views/errors/

Author: mfojtik
Date: Tue May  3 14:33:36 2011
New Revision: 1099077

URL: http://svn.apache.org/viewvc?rev=1099077&view=rev
Log:
Added more detailed descriptions to error codes and more debugging output, like HTTP headers

Fixed special cases when no exception was throwed, just status code.
Improved wraping for backtrace in error pages.

Added:
    incubator/deltacloud/trunk/server/views/errors/405.html.haml
    incubator/deltacloud/trunk/server/views/errors/405.xml.haml
    incubator/deltacloud/trunk/server/views/errors/500.html.haml
Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
    incubator/deltacloud/trunk/server/public/stylesheets/compiled/application.css
    incubator/deltacloud/trunk/server/views/errors/400.html.haml
    incubator/deltacloud/trunk/server/views/errors/401.html.haml
    incubator/deltacloud/trunk/server/views/errors/403.html.haml
    incubator/deltacloud/trunk/server/views/errors/404.html.haml
    incubator/deltacloud/trunk/server/views/errors/404.xml.haml
    incubator/deltacloud/trunk/server/views/errors/500.xml.haml
    incubator/deltacloud/trunk/server/views/errors/502.html.haml

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb Tue May  3 14:33:36 2011
@@ -105,11 +105,19 @@ module ApplicationHelper
   end
 
   def report_error(code=nil)
-    @error = request.env['sinatra.error']
-    response.status = code || @error.code
+    @error, @code = request.env['sinatra.error'], code
+    @code = 500 if not @code and not @error.class.method_defined? :code
+    if @error
+      unless @error.class.method_defined? :cause
+        @cause = nil
+      else
+        @cause = @error.cause
+      end
+    end
+    response.status = @code || @error.code
     respond_to do |format|
-      format.xml { haml :"errors/#{code || @error.code}", :layout => false }
-      format.html { haml :"errors/#{code || @error.code}", :layout => :error }
+      format.xml { haml :"errors/#{@code || @error.code}", :layout => false }
+      format.html { haml :"errors/#{@code || @error.code}", :layout => :error }
     end
   end
 

Modified: incubator/deltacloud/trunk/server/public/stylesheets/compiled/application.css
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/public/stylesheets/compiled/application.css?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/public/stylesheets/compiled/application.css (original)
+++ incubator/deltacloud/trunk/server/public/stylesheets/compiled/application.css Tue May  3 14:33:36 2011
@@ -667,3 +667,11 @@ h3.description {
   font-size : 70%;
   color : #ccc;
 }
+
+pre {
+  white-space: pre-wrap; /* css-3 */
+  white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
+  white-space: -pre-wrap; /* Opera 4-6 */
+  white-space: -o-pre-wrap; /* Opera 7 */
+  word-wrap: break-word; /* Internet Explorer 5.5+ */
+}

Modified: incubator/deltacloud/trunk/server/views/errors/400.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/400.html.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/400.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/400.html.haml Tue May  3 14:33:36 2011
@@ -1,4 +1,4 @@
-%h1 Validation Failure
+%h1 Bad Request
 
 %p= @error.message
 
@@ -9,3 +9,10 @@
   %di
     %dt Parameter
     %dd= @error.name
+  %di
+    %dt Status code
+    %dd= response.status
+  %di
+    %dt Explanation
+    %dd
+      The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

Modified: incubator/deltacloud/trunk/server/views/errors/401.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/401.html.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/401.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/401.html.haml Tue May  3 14:33:36 2011
@@ -6,3 +6,6 @@
   %di
     %dt Request URL
     %dd= request.env['REQUEST_URI']
+  %di
+    %dt Status code
+    %dd= response.status

Modified: incubator/deltacloud/trunk/server/views/errors/403.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/403.html.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/403.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/403.html.haml Tue May  3 14:33:36 2011
@@ -1,6 +1,16 @@
-%h1 Method Not Allowed
+%h1 Forbidden
 
 %dl
   %di
     %dt Request URL
     %dd= request.env['REQUEST_URI']
+  %di
+    %dt Cause
+    %dd= @cause
+  %di
+    %dt Status code
+    %dd= response.status
+  %di
+    %dt Explanation
+    %dd
+      The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.

Modified: incubator/deltacloud/trunk/server/views/errors/404.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/404.html.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/404.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/404.html.haml Tue May  3 14:33:36 2011
@@ -1,6 +1,13 @@
-%h1 Not Found
+%h1 Resource not found
 
 %dl
   %di
     %dt Request URL
     %dd= request.env['REQUEST_URI']
+  %di
+    %dt Status code
+    %dd= response.status
+  %di
+    %dt Explanation
+    %dd
+      The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. 

Modified: incubator/deltacloud/trunk/server/views/errors/404.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/404.xml.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/404.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/404.xml.haml Tue May  3 14:33:36 2011
@@ -1,2 +1,2 @@
 %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
-  %message Not Found
+  %message Resource not found

Added: incubator/deltacloud/trunk/server/views/errors/405.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/405.html.haml?rev=1099077&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/405.html.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/405.html.haml Tue May  3 14:33:36 2011
@@ -0,0 +1,21 @@
+%h1 Method Not Allowed
+
+%p
+  A 405 status code is returned when the client has tried to use a request method that the server does not allow. Request methods that are allowed should be sent with the response (common request methods are POST and GET).
+
+%dl
+  %di
+    %dt Request URL
+    %dd= request.env['REQUEST_URI']
+  %di
+    %dt Request headers
+    %dd
+      %pre
+        =request.env.inspect
+  %di
+    %dt Status code
+    %dd= response.status
+  %di
+    %dt Explanation
+    %dd
+      The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.

Added: incubator/deltacloud/trunk/server/views/errors/405.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/405.xml.haml?rev=1099077&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/405.xml.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/405.xml.haml Tue May  3 14:33:36 2011
@@ -0,0 +1,5 @@
+%error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
+  %message
+    Requested method not allowed
+  %method
+    =request.env['REQUEST_METHOD']

Added: incubator/deltacloud/trunk/server/views/errors/500.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/500.html.haml?rev=1099077&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/500.html.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/500.html.haml Tue May  3 14:33:36 2011
@@ -0,0 +1,37 @@
+%h1 Internal Server Error
+
+%p= "#{@error.class}: #{@error.message}"
+- if @error.class.method_defined? :details
+  %p= @error.details
+
+%dl
+  %di
+    %dt Request URL
+    %dd= request.env['REQUEST_URI']
+  %di
+    %dt Request headers
+    %dd
+      %pre
+        =request.env.inspect
+  %di
+    %dt Parameters
+    %dd
+      %pre
+        =params.inspect
+  %di
+    %dt Response headers
+    %dd
+      %pre
+        =response.headers.inspect
+  %di
+    %dt Code
+    %dd 500
+  %di
+    %dt Backtrace
+    %dd
+      %pre
+        =@error.backtrace.join("\n")
+  %di
+    %dt Explanation
+    %dd
+      The server encountered an unexpected condition which prevented it from fulfilling the request.

Modified: incubator/deltacloud/trunk/server/views/errors/500.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/500.xml.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/500.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/500.xml.haml Tue May  3 14:33:36 2011
@@ -1,8 +1,8 @@
 %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
   %kind backend_error
   %backend{ :driver => driver_symbol }
-    %code= @error.code
-    %cause= @error.cause
-    - if @error.details
+    %code=response.status
+    %cause= @cause
+    - if @error.class.method_defined? :details
       %details< #{cdata @error.details.join("\n")}
   %message< #{cdata @error.message}

Modified: incubator/deltacloud/trunk/server/views/errors/502.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/502.html.haml?rev=1099077&r1=1099076&r2=1099077&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/502.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/errors/502.html.haml Tue May  3 14:33:36 2011
@@ -1,4 +1,4 @@
-%h1 Backend Error
+%h1 Backend provider error
 
 %p= @error.message
 
@@ -12,3 +12,7 @@
   %di
     %dt Code
     %dd= @error.code
+  %di
+    %dt Explanation
+    %dd
+      The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.