Make exception in ensure stage service more descriptive
This commit is contained in:
parent
e178135d57
commit
708059bd9a
|
@ -7,7 +7,7 @@ module Ci
|
|||
# stage.
|
||||
#
|
||||
class EnsureStageService < BaseService
|
||||
PipelineStageError = Class.new(StandardError)
|
||||
EnsureStageError = Class.new(StandardError)
|
||||
|
||||
def execute(build)
|
||||
@build = build
|
||||
|
@ -28,7 +28,10 @@ module Ci
|
|||
find_stage || create_stage
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
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
|
||||
|
||||
def find_stage
|
||||
|
|
|
@ -45,7 +45,7 @@ describe Ci::EnsureStageService, '#execute' do
|
|||
expect(service).to receive(:find_stage).exactly(2).times
|
||||
|
||||
expect { service.execute(job) }
|
||||
.to raise_error(Ci::EnsureStageService::PipelineStageError)
|
||||
.to raise_error(Ci::EnsureStageService::EnsureStageError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue