[ARVADOS] created: b6ee157889043600b012f33382da0347d07ee211

git at public.curoverse.com git at public.curoverse.com
Wed Jul 23 16:58:52 EDT 2014


        at  b6ee157889043600b012f33382da0347d07ee211 (commit)


commit b6ee157889043600b012f33382da0347d07ee211
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Jul 23 16:50:18 2014 -0400

    3200: Improve error handling in Workbench's API client.
    
    * Fix the class used for error responses that can be parsed but don't
      have a dedicated subclass.
    
    * Ensure that exception.api_response[:errors] is always an array.
    
    This improves the error reporting for #3207.

diff --git a/apps/workbench/app/models/arvados_api_client.rb b/apps/workbench/app/models/arvados_api_client.rb
index 9f34a29..78d3bee 100644
--- a/apps/workbench/app/models/arvados_api_client.rb
+++ b/apps/workbench/app/models/arvados_api_client.rb
@@ -8,6 +8,10 @@ class ArvadosApiClient
     def initialize(request_url, errmsg)
       @request_url = request_url
       @api_response ||= {}
+      errors = @api_response[:errors]
+      if not errors.is_a?(Array)
+        @api_response[:errors] = [errors || errmsg]
+      end
       super(errmsg)
     end
   end
@@ -138,7 +142,8 @@ class ArvadosApiClient
     if not resp.is_a? Hash
       raise InvalidApiResponseException.new(url, msg)
     elsif msg.status_code != 200
-      error_class = ERROR_CODE_CLASSES.fetch(msg.status_code, ApiError)
+      error_class = ERROR_CODE_CLASSES.fetch(msg.status_code,
+                                             ApiErrorResponseException)
       raise error_class.new(url, msg)
     end
 

commit d18a6abe014469a2f6def95f379ad91c339c9b37
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Jul 23 16:29:12 2014 -0400

    3200: X-Editable renders errors even without a message array.
    
    The previous version was causing the X-Editable popup to spin
    infinitely when the JSON errors were null.  See #3207, #3251.

diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js
index ab66833..76a129b 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/editable.js
@@ -58,7 +58,16 @@ $(document).
                     return;
                 },
                 error: function(response, newValue) {
-                    return response.responseJSON.errors.join();
+                    var errlist = response.responseJSON.errors;
+                    var errmsg;
+                    if (Array.isArray(errlist)) {
+                        errmsg = errlist.join();
+                    } else {
+                        errmsg = ("The server returned an error when making " +
+                                  "this update (status " + response.status +
+                                  ": " + errlist + ").");
+                    }
+                    return errmsg;
                 }
             }).
             on('hidden', function(e, reason) {

commit 4f2b39a5ba854d39449d993ff3401d7c5aa20dc4
Author: Brett Smith <brett at curoverse.com>
Date:   Tue Jul 22 18:04:58 2014 -0400

    3200: Workbench copes better when a tab fails to load.

diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
index ec4a519..7865878 100644
--- a/apps/workbench/app/assets/javascripts/tab_panes.js
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -12,6 +12,44 @@ $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
         done(function(data, status, jqxhr) {
             $('> div > div', this).html(data);
             $(this).addClass('loaded');
+        }).fail(function(jqxhr, status, error) {
+            var errhtml;
+            if (jqxhr.getResponseHeader('Content-Type').match(/\btext\/html\b/)) {
+                var $response = $(jqxhr.responseText);
+                var $wrapper = $('div#page-wrapper', $response);
+                if ($wrapper.length) {
+                    errhtml = $wrapper.html();
+                } else {
+                    errhtml = jqxhr.responseText;
+                }
+            } else {
+                errhtml = (jqxhr.responseText ||
+                           'The server returned an error when loading this tab.').
+                    replace(/&/g, '&').
+                    replace(/</g, '<').
+                    replace(/>/g, '>');
+            }
+            $('> div > div', this).html(
+                '<div><iframe></iframe>' +
+                    '<p><a href="#" class="btn btn-primary tab_reload">' +
+                    '<i class="fa fa-fw fa-refresh"></i> ' +
+                    'Reload tab</a></p></div>');
+            $('.tab_reload', this).click(function() {
+                $('> div > div', $pane).html(
+                    '<div class="spinner spinner-32px spinner-h-center"></div>');
+                $pane.trigger('arv:pane:reload');
+            });
+            // We want to render the error in an iframe, in order to
+            // avoid conflicts with the main page's element ids, etc.
+            // In order to do that dynamically, we have to set a
+            // timeout on the iframe window to load our HTML *after*
+            // the default source (e.g., about:blank) has loaded.
+            var iframe = $('iframe', this)[0];
+            iframe.contentWindow.setTimeout(function() {
+                $('body', iframe.contentDocument).html(errhtml);
+                iframe.height = iframe.contentDocument.body.scrollHeight + "px";
+            }, 1);
+            $(this).addClass('loaded');
         });
 });
 
diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss
index e3f4f0a..75d58ed 100644
--- a/apps/workbench/app/assets/stylesheets/application.css.scss
+++ b/apps/workbench/app/assets/stylesheets/application.css.scss
@@ -235,3 +235,8 @@ div#wrapper {
 svg text {
     font-size: 6pt;
 }
+
+div.pane-content iframe {
+  width: 100%;
+  border: none;
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list