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
include Presentable
include Importable
MissingDependenciesError = Class.new(StandardError)
belongs_to :runner
belongs_to :trigger_request
belongs_to :erased_by, class_name: 'User'
......@@ -141,8 +143,8 @@ module Ci
end
before_transition any => [:running] do |build|
if !build.empty_dependencies? && build.dependencies.empty?
raise Gitlab::Ci::Error::MissingDependencies
if build.specified_dependencies? && build.dependencies.empty?
raise MissingDependenciesError
end
end
end
......@@ -484,6 +486,10 @@ module Ci
options[:dependencies]&.empty?
end
def specified_dependencies?
options.has_key?(:dependencies) && options[:dependencies].any?
end
def hide_secrets(trace)
return unless trace
......
......@@ -54,7 +54,7 @@ module Ci
# we still have to return 409 in the end,
# to make sure that this is properly handled by runner.
valid = false
rescue Gitlab::Ci::Error::MissingDependencies
rescue Ci::Build::MissingDependenciesError
build.drop!(:missing_dependency_failure)
valid = false
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
end
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
......
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