Commit 0d5d772f authored by gaga5lala's avatar gaga5lala Committed by Imre Farkas

Only log CarrierWave::IntegrityError without sending exception

parent 9bcc657e
......@@ -48,6 +48,9 @@ module DesignManagement
# Store and process the file
action.image_v432x230.store!(raw_file)
action.save!
rescue CarrierWave::IntegrityError => e
Gitlab::ErrorTracking.log_exception(e, project_id: project.id, design_id: action.design_id, version_id: action.version_id)
log_error(e.message)
rescue CarrierWave::UploadError => e
Gitlab::ErrorTracking.track_exception(e, project_id: project.id, design_id: action.design_id, version_id: action.version_id)
log_error(e.message)
......
---
title: Log CarrierWave::IntegrityError without sending exception
merge_request: 43750
author: gaga5lala
type: other
......@@ -52,9 +52,33 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
end
context 'when an error is encountered when generating the image versions' do
context "CarrierWave::IntegrityError" do
before do
expect_next_instance_of(DesignManagement::DesignV432x230Uploader) do |uploader|
expect(uploader).to receive(:cache!).and_raise(CarrierWave::DownloadError, 'foo')
expect(uploader).to receive(:cache!).and_raise(CarrierWave::IntegrityError, 'foo')
end
end
it 'logs the exception' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(CarrierWave::IntegrityError),
project_id: project.id, version_id: version.id, design_id: version.designs.first.id
)
described_class.new(version).execute
end
it 'logs the error' do
expect(Gitlab::AppLogger).to receive(:error).with('foo')
described_class.new(version).execute
end
end
context "CarrierWave::UploadError" do
before do
expect_next_instance_of(DesignManagement::DesignV432x230Uploader) do |uploader|
expect(uploader).to receive(:cache!).and_raise(CarrierWave::UploadError, 'foo')
end
end
......@@ -66,7 +90,7 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
it 'tracks the error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(CarrierWave::DownloadError),
instance_of(CarrierWave::UploadError),
project_id: project.id, version_id: version.id, design_id: version.designs.first.id
)
......@@ -74,4 +98,5 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment