[ARVADOS] created: 1.1.3-211-g270b929

Git user git at public.curoverse.com
Wed Mar 14 14:48:05 EDT 2018


        at  270b9295100b50419da8911ea080d025cd52d773 (commit)


commit 270b9295100b50419da8911ea080d025cd52d773
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Wed Mar 14 14:46:22 2018 -0400

    13138: Gather arvados API errors under "RequestError" class.
    
    Don't print stack trace for RequestError, because they are expected
    conditions when there is an error in the request.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index c4f64f6..ba7c07d 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -3,6 +3,7 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 require 'safe_json'
+require 'request_error'
 
 module ApiTemplateOverride
   def allowed_to_render?(fieldset, field, model, options)
@@ -137,7 +138,7 @@ class ApplicationController < ActionController::Base
 
   def render_error(e)
     logger.error e.inspect
-    if e.respond_to? :backtrace and e.backtrace
+    if !e.is_a? RequestError and (e.respond_to? :backtrace and e.backtrace)
       logger.error e.backtrace.collect { |x| x + "\n" }.join('')
     end
     if (@object.respond_to? :errors and
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 05deba7..962ca4a 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -5,6 +5,7 @@
 require 'has_uuid'
 require 'record_filters'
 require 'serializers'
+require 'request_error'
 
 class ArvadosModel < ActiveRecord::Base
   self.abstract_class = true
@@ -38,37 +39,37 @@ class ArvadosModel < ActiveRecord::Base
            class_name: 'Link',
            primary_key: :uuid)
 
-  class PermissionDeniedError < StandardError
+  class PermissionDeniedError < RequestError
     def http_status
       403
     end
   end
 
-  class AlreadyLockedError < StandardError
+  class AlreadyLockedError < RequestError
     def http_status
       422
     end
   end
 
-  class LockFailedError < StandardError
+  class LockFailedError < RequestError
     def http_status
       422
     end
   end
 
-  class InvalidStateTransitionError < StandardError
+  class InvalidStateTransitionError < RequestError
     def http_status
       422
     end
   end
 
-  class UnauthorizedError < StandardError
+  class UnauthorizedError < RequestError
     def http_status
       401
     end
   end
 
-  class UnresolvableContainerError < StandardError
+  class UnresolvableContainerError < RequestError
     def http_status
       422
     end
diff --git a/services/api/app/models/blob.rb b/services/api/app/models/blob.rb
index 3cf1063..55a2578 100644
--- a/services/api/app/models/blob.rb
+++ b/services/api/app/models/blob.rb
@@ -2,6 +2,8 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+require 'request_error'
+
 class Blob
   extend DbCurrentTime
 
@@ -25,8 +27,8 @@ class Blob
   #     locator_hash +A blob_signature @ timestamp
   # where the timestamp is a Unix time expressed as a hexadecimal value,
   # and the blob_signature is the signed locator_hash + API token + timestamp.
-  # 
-  class InvalidSignatureError < StandardError
+  #
+  class InvalidSignatureError < RequestError
   end
 
   # Blob.sign_locator: return a signed and timestamped blob locator.
diff --git a/services/api/app/models/commit.rb b/services/api/app/models/commit.rb
index 19254ce..921c690 100644
--- a/services/api/app/models/commit.rb
+++ b/services/api/app/models/commit.rb
@@ -2,10 +2,12 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+require 'request_error'
+
 class Commit < ActiveRecord::Base
   extend CurrentApiClient
 
-  class GitError < StandardError
+  class GitError < RequestError
     def http_status
       422
     end
diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 8de3897..7508ead 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -33,7 +33,7 @@ class Job < ArvadosModel
   has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
   has_many(:nodes, foreign_key: :job_uuid, primary_key: :uuid)
 
-  class SubmitIdReused < StandardError
+  class SubmitIdReused < RequestError
   end
 
   api_accessible :user, extend: :common do |t|
diff --git a/services/api/lib/request_error.rb b/services/api/lib/request_error.rb
new file mode 100644
index 0000000..cd9f9f8
--- /dev/null
+++ b/services/api/lib/request_error.rb
@@ -0,0 +1,6 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class RequestError < StandardError
+end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list