Log error message inline when Feeds::Import fails (#12012)

This commit is contained in:
rhymes 2020-12-22 20:02:07 +01:00 committed by GitHub
parent 92fdf8d720
commit 00247bed99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -151,8 +151,9 @@ module Feeds
end
def report_error(error, metadata)
Rails.logger.error("feeds::import::error::#{error.class}::#{metadata}")
Rails.logger.error(error)
Rails.logger.error(
"feeds::import::error::#{error.class}::#{metadata.merge(error_message: error.message)}",
)
end
def item_count_error(feed)

View file

@ -96,6 +96,15 @@ RSpec.describe Feeds::Import, type: :service, vcr: true, db_strategy: :truncatio
expect(Rails.logger).to have_received(:error).at_least(:once)
end
it "logs the error message" do
allow(Feedjira).to receive(:parse).and_raise("this is an error")
allow(Rails.logger).to receive(:error)
described_class.call
expect(Rails.logger).to have_received(:error).at_least(:once).with(/error_message=>"this is an error"/)
end
end
context "with an explicit set of users", vcr: { cassette_name: "feeds_import" } do