Commit 6e343b27 authored by Shinya Maeda's avatar Shinya Maeda

Use Class.new(StandardError) instead of custom extended error class. Bring...

Use Class.new(StandardError) instead of custom extended error class. Bring back specified_dependencies?.
parent 8917726b
...@@ -6,6 +6,8 @@ module Ci ...@@ -6,6 +6,8 @@ module Ci
include Presentable include Presentable
include Importable include Importable
MissingDependenciesError = Class.new(StandardError)
belongs_to :runner belongs_to :runner
belongs_to :trigger_request belongs_to :trigger_request
belongs_to :erased_by, class_name: 'User' belongs_to :erased_by, class_name: 'User'
...@@ -141,8 +143,8 @@ module Ci ...@@ -141,8 +143,8 @@ module Ci
end end
before_transition any => [:running] do |build| before_transition any => [:running] do |build|
if !build.empty_dependencies? && build.dependencies.empty? if build.specified_dependencies? && build.dependencies.empty?
raise Gitlab::Ci::Error::MissingDependencies raise MissingDependenciesError
end end
end end
end end
...@@ -484,6 +486,10 @@ module Ci ...@@ -484,6 +486,10 @@ module Ci
options[:dependencies]&.empty? options[:dependencies]&.empty?
end end
def specified_dependencies?
options.has_key?(:dependencies) && options[:dependencies].any?
end
def hide_secrets(trace) def hide_secrets(trace)
return unless trace return unless trace
......
...@@ -54,7 +54,7 @@ module Ci ...@@ -54,7 +54,7 @@ module Ci
# we still have to return 409 in the end, # we still have to return 409 in the end,
# to make sure that this is properly handled by runner. # to make sure that this is properly handled by runner.
valid = false valid = false
rescue Gitlab::Ci::Error::MissingDependencies rescue Ci::Build::MissingDependenciesError
build.drop!(:missing_dependency_failure) build.drop!(:missing_dependency_failure)
valid = false valid = false
end end
......
module Gitlab
module Ci
module Error
class MissingDependencies < StandardError; end
end
end
end
require 'spec_helper'
describe Gitlab::Ci::Error::MissingDependencies do
it { expect(described_class).to be < StandardError }
end
...@@ -1893,7 +1893,7 @@ describe Ci::Build do ...@@ -1893,7 +1893,7 @@ describe Ci::Build do
end end
context 'when depended jobs do not exist' do context 'when depended jobs do not exist' do
it { expect { build.run! }.to raise_error(Gitlab::Ci::Error::MissingDependencies) } it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
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