Merge branch '2891-improve-workbench-errors'
[arvados.git] / apps / workbench / app / models / arvados_api_client.rb
index f36627f07b62e5034a05301791655bb7cf6ab881..9f34a29e5bfffb2c5df33299cb9b3b0181509681 100644 (file)
@@ -12,6 +12,13 @@ class ArvadosApiClient
     end
   end
 
+  class NoApiResponseException < ApiError
+    def initialize(request_url, exception)
+      @api_response_s = exception.to_s
+      super(request_url,
+            "#{exception.class.to_s} error connecting to API server")
+    end
+  end
 
   class InvalidApiResponseException < ApiError
     def initialize(request_url, api_response)
@@ -115,9 +122,11 @@ class ArvadosApiClient
 
     profile_checkpoint { "Prepare request #{url} #{query[:uuid]} #{query[:where]} #{query[:filters]}" }
     msg = @client_mtx.synchronize do
-      @api_client.post(url,
-                       query,
-                       header: header)
+      begin
+        @api_client.post(url, query, header: header)
+      rescue => exception
+        raise NoApiResponseException.new(url, exception)
+      end
     end
     profile_checkpoint 'API transaction'