Commit 3566fb4b authored by Fabio Pitino's avatar Fabio Pitino

Use a shared error class

parent 6367fa99
...@@ -10,6 +10,7 @@ module Ci ...@@ -10,6 +10,7 @@ module Ci
include HasRef include HasRef
InvalidBridgeTypeError = Class.new(StandardError) InvalidBridgeTypeError = Class.new(StandardError)
InvalidTransitionError = Class.new(StandardError)
belongs_to :project belongs_to :project
belongs_to :trigger_request belongs_to :trigger_request
......
...@@ -6,7 +6,6 @@ module Ci ...@@ -6,7 +6,6 @@ module Ci
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
DuplicateDownstreamPipelineError = Class.new(StandardError) DuplicateDownstreamPipelineError = Class.new(StandardError)
InvalidBridgeTransition = Class.new(StandardError)
def execute(bridge) def execute(bridge)
@bridge = bridge @bridge = bridge
...@@ -55,7 +54,7 @@ module Ci ...@@ -55,7 +54,7 @@ module Ci
end end
rescue StateMachines::InvalidTransition => e rescue StateMachines::InvalidTransition => e
Gitlab::ErrorTracking.track_exception( Gitlab::ErrorTracking.track_exception(
InvalidBridgeTransition.new(e.message), Ci::Bridge::InvalidTransitionError.new(e.message),
bridge_id: bridge.id, bridge_id: bridge.id,
downstream_pipeline_id: pipeline.id) downstream_pipeline_id: pipeline.id)
end end
......
...@@ -8,7 +8,8 @@ module Ci ...@@ -8,7 +8,8 @@ module Ci
begin begin
pipeline.source_bridge.inherit_status_from_downstream!(pipeline) pipeline.source_bridge.inherit_status_from_downstream!(pipeline)
rescue StateMachines::InvalidTransition => e rescue StateMachines::InvalidTransition => e
Gitlab::ErrorTracking.track_exception(e, Gitlab::ErrorTracking.track_exception(
Ci::Bridge::InvalidTransitionError.new(e.message),
bridge_id: pipeline.source_bridge.id, bridge_id: pipeline.source_bridge.id,
downstream_pipeline_id: pipeline.id) downstream_pipeline_id: pipeline.id)
end end
......
...@@ -374,7 +374,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do ...@@ -374,7 +374,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
expect(Gitlab::ErrorTracking) expect(Gitlab::ErrorTracking)
.to receive(:track_exception) .to receive(:track_exception)
.with( .with(
instance_of(Ci::CreateCrossProjectPipelineService::InvalidBridgeTransition), instance_of(Ci::Bridge::InvalidTransitionError),
bridge_id: bridge.id, bridge_id: bridge.id,
downstream_pipeline_id: kind_of(Numeric)) downstream_pipeline_id: kind_of(Numeric))
......
...@@ -33,7 +33,7 @@ describe Ci::PipelineBridgeStatusService do ...@@ -33,7 +33,7 @@ describe Ci::PipelineBridgeStatusService do
expect(Gitlab::ErrorTracking) expect(Gitlab::ErrorTracking)
.to receive(:track_exception) .to receive(:track_exception)
.with( .with(
instance_of(StateMachines::InvalidTransition), instance_of(Ci::Bridge::InvalidTransitionError),
bridge_id: bridge.id, bridge_id: bridge.id,
downstream_pipeline_id: pipeline.id) downstream_pipeline_id: pipeline.id)
......
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