From 9a9a0274839b895fe21adcf68b4832ca2c4ff74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 3 Sep 2018 15:48:06 +0200 Subject: [PATCH] Improve error logging when text cannot be extracted [ci skip] --- app/workers/extract_fulltext_job.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/workers/extract_fulltext_job.rb b/app/workers/extract_fulltext_job.rb index ae10a94d91..aa0fd5759b 100644 --- a/app/workers/extract_fulltext_job.rb +++ b/app/workers/extract_fulltext_job.rb @@ -49,17 +49,19 @@ class ExtractFulltextJob < ApplicationJob private def init - carrierwave_uploader = @attachment.file - @file = carrierwave_uploader.local_file - @filename = carrierwave_uploader.file.filename - begin + carrierwave_uploader = @attachment.file + @file = carrierwave_uploader.local_file + @filename = carrierwave_uploader.file.filename + if @attachment.readable? resolver = Plaintext::Resolver.new(@file, @attachment.content_type) @text = resolver.text end rescue => e - Rails.logger.error e.message + Rails.logger.error { + "Failed to extract plaintext from file #{@attachment.id} (On domain #{Setting.host_name}): #{e}: #{e.message}" + } end end