Commit 708059bd authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make exception in ensure stage service more descriptive

parent e178135d
...@@ -7,7 +7,7 @@ module Ci ...@@ -7,7 +7,7 @@ module Ci
# stage. # stage.
# #
class EnsureStageService < BaseService class EnsureStageService < BaseService
PipelineStageError = Class.new(StandardError) EnsureStageError = Class.new(StandardError)
def execute(build) def execute(build)
@build = build @build = build
...@@ -28,7 +28,10 @@ module Ci ...@@ -28,7 +28,10 @@ module Ci
find_stage || create_stage find_stage || create_stage
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
retry if (attempts -= 1) > 0 retry if (attempts -= 1) > 0
raise PipelineStageError, 'Fix me!' raise EnsureStageError, <<~EOS
Possible bug in the database load balancing detected!
Please fix me!
EOS
end end
def find_stage def find_stage
......
...@@ -45,7 +45,7 @@ describe Ci::EnsureStageService, '#execute' do ...@@ -45,7 +45,7 @@ describe Ci::EnsureStageService, '#execute' do
expect(service).to receive(:find_stage).exactly(2).times expect(service).to receive(:find_stage).exactly(2).times
expect { service.execute(job) } expect { service.execute(job) }
.to raise_error(Ci::EnsureStageService::PipelineStageError) .to raise_error(Ci::EnsureStageService::EnsureStageError)
end 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