Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb')
-rw-r--r--gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb b/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
index faabddd2686..eaaa90ec52b 100644
--- a/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
+++ b/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
@@ -7,6 +7,7 @@ module ActiveRecord
#
# - `ActiveRecord::Relation#load`, and other methods that call
# `ActiveRecord::Relation#exec_queries`.
+ # - `ActiveModel::UnknownAttributeError` as a result of `ActiveRecord::Base#assign_attributes`
#
# class ApplicationRecord < ActiveRecord::Base
# rescue_from MyException, with: :my_handler
@@ -29,13 +30,23 @@ module ActiveRecord
def exec_queries
super
rescue StandardError => e
+ # Method klass is defined in ActiveRecord gem lib/active_record/relation.rb
klass.rescue_with_handler(e) || raise
end
end
+
+ module AssignAttributesRescueWithHandler
+ def _assign_attributes(...)
+ super(...)
+ rescue StandardError => e
+ rescue_with_handler(e) || raise
+ end
+ end
end
end
ActiveSupport.on_load(:active_record) do
ActiveRecord::Relation.prepend(ActiveRecord::GitlabPatches::ExecQueriesRescueWithHandler)
+ ActiveRecord::Base.prepend(ActiveRecord::GitlabPatches::AssignAttributesRescueWithHandler)
ActiveRecord::Base.prepend(ActiveRecord::GitlabPatches::RescueFrom)
end