Make exception in ensure stage service more descriptive

This commit is contained in:
Grzegorz Bizon 2018-02-06 10:02:33 +01:00
parent e178135d57
commit 708059bd9a
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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