diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index b443a45437..9f48dd75c9 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -227,7 +227,13 @@ def form_err_msg(form) end def transaction_err_msg(result) - result.failure.first + msg = if result.failure[1].respond_to?(:full_messages) + "#{result.failure[1].full_messages.to_sentence} [#{result.failure[0]}]" + else + result.failure[0].to_s + end + Rails.logger.info("Transaction failed: #{msg}\n #{result.trace}") + msg end def presenter diff --git a/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb b/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb index 27e1b99cef..f248c243bf 100644 --- a/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +++ b/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb @@ -33,7 +33,7 @@ def find_parent_work(resource:) if results.count > 1 Hyrax.logger.warn("#{resource.work? ? 'Work' : 'File set'} " \ "#{resource.id} is in #{results.count} works when it " \ - "should be in no more than one.") + "should be in no more than one. Found in #{results.map(&:id).join(', ')}.") end results.first end diff --git a/spec/services/hyrax/custom_queries/navigators/parent_work_navigator_spec.rb b/spec/services/hyrax/custom_queries/navigators/parent_work_navigator_spec.rb index e72a618778..2d7dfc41d9 100644 --- a/spec/services/hyrax/custom_queries/navigators/parent_work_navigator_spec.rb +++ b/spec/services/hyrax/custom_queries/navigators/parent_work_navigator_spec.rb @@ -29,7 +29,7 @@ let(:child_work3) { FactoryBot.valkyrie_create(:hyrax_work, id: 'cw3', title: ['Child Work 3']) } let(:member_ids) { [child_work3.id] } it 'logs warning about more than one parent and returns the first parent work as Valkyrie resources' do - expect(Hyrax.logger).to receive(:warn).with("Work cw3 is in 2 works when it should be in no more than one.") + expect(Hyrax.logger).to receive(:warn).with("Work cw3 is in 2 works when it should be in no more than one. Found in pw1, pw2.") parent = custom_query_service.find_parent_work(resource: child_work3) # There is no guarantee which of the parents will be returned. expect([work.id, parent_work.id]).to include parent.id @@ -47,7 +47,7 @@ let(:fileset3) { FactoryBot.valkyrie_create(:hyrax_file_set, id: 'fs3', title: ['Child File Set 3']) } let(:member_ids) { [fileset3.id] } it 'logs warning about more than one parent and returns the first parent work as Valkyrie resources' do - expect(Hyrax.logger).to receive(:warn).with("File set fs3 is in 2 works when it should be in no more than one.") + expect(Hyrax.logger).to receive(:warn).with("File set fs3 is in 2 works when it should be in no more than one. Found in pw1, pw2.") parent = custom_query_service.find_parent_work(resource: fileset3) # There is no guarantee which of the parents will be returned. expect([work.id, parent_work.id]).to include parent.id