Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0d5d772f
Commit
0d5d772f
authored
Oct 01, 2020
by
gaga5lala
Committed by
Imre Farkas
Oct 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only log CarrierWave::IntegrityError without sending exception
parent
9bcc657e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
13 deletions
+46
-13
app/services/design_management/generate_image_versions_service.rb
...ices/design_management/generate_image_versions_service.rb
+3
-0
changelogs/unreleased/gaga5lala-227175-carrierwave-error-handle.yml
.../unreleased/gaga5lala-227175-carrierwave-error-handle.yml
+5
-0
spec/services/design_management/generate_image_versions_service_spec.rb
...design_management/generate_image_versions_service_spec.rb
+38
-13
No files found.
app/services/design_management/generate_image_versions_service.rb
View file @
0d5d772f
...
@@ -48,6 +48,9 @@ module DesignManagement
...
@@ -48,6 +48,9 @@ module DesignManagement
# Store and process the file
# Store and process the file
action
.
image_v432x230
.
store!
(
raw_file
)
action
.
image_v432x230
.
store!
(
raw_file
)
action
.
save!
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
rescue
CarrierWave
::
UploadError
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
project_id:
project
.
id
,
design_id:
action
.
design_id
,
version_id:
action
.
version_id
)
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
project_id:
project
.
id
,
design_id:
action
.
design_id
,
version_id:
action
.
version_id
)
log_error
(
e
.
message
)
log_error
(
e
.
message
)
...
...
changelogs/unreleased/gaga5lala-227175-carrierwave-error-handle.yml
0 → 100644
View file @
0d5d772f
---
title
:
Log CarrierWave::IntegrityError without sending exception
merge_request
:
43750
author
:
gaga5lala
type
:
other
spec/services/design_management/generate_image_versions_service_spec.rb
View file @
0d5d772f
...
@@ -52,25 +52,50 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
...
@@ -52,25 +52,50 @@ RSpec.describe DesignManagement::GenerateImageVersionsService do
end
end
context
'when an error is encountered when generating the image versions'
do
context
'when an error is encountered when generating the image versions'
do
before
do
context
"CarrierWave::IntegrityError"
do
expect_next_instance_of
(
DesignManagement
::
DesignV432x230Uploader
)
do
|
uploader
|
before
do
expect
(
uploader
).
to
receive
(
:cache!
).
and_raise
(
CarrierWave
::
DownloadError
,
'foo'
)
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
end
it
'logs the error'
do
it
'logs the error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'foo'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'foo'
)
described_class
.
new
(
version
).
execute
described_class
.
new
(
version
).
execute
end
end
end
it
'tracks the error'
do
context
"CarrierWave::UploadError"
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
before
do
instance_of
(
CarrierWave
::
DownloadError
),
expect_next_instance_of
(
DesignManagement
::
DesignV432x230Uploader
)
do
|
uploader
|
project_id:
project
.
id
,
version_id:
version
.
id
,
design_id:
version
.
designs
.
first
.
id
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
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment