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,25 +52,50 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
end
context 'when an error is encountered when generating the image versions' do
before do
expect_next_instance_of(DesignManagement::DesignV432x230Uploader) do |uploader|
expect(uploader).to receive(:cache!).and_raise(CarrierWave::DownloadError, 'foo')
context "CarrierWave::IntegrityError" do
before do
expect_next_instance_of(DesignManagement::DesignV432x230Uploader) do |uploader|
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
end
it 'logs the error' do
expect(Gitlab::AppLogger).to receive(:error).with('foo')
it 'logs the error' do
expect(Gitlab::AppLogger).to receive(:error).with('foo')
described_class.new(version).execute
described_class.new(version).execute
end
end
it 'tracks the error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(CarrierWave::DownloadError),
project_id: project.id, version_id: version.id, design_id: version.designs.first.id
)
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
described_class.new(version).execute
it 'logs the error' do
expect(Gitlab::AppLogger).to receive(:error).with('foo')
described_class.new(version).execute
end
it 'tracks the error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(CarrierWave::UploadError),
project_id: project.id, version_id: version.id, design_id: version.designs.first.id
)
described_class.new(version).execute
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