From 2243f0e3deaf0c9557fdc971e566b5606e9e9c52 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 18 Oct 2018 11:06:32 +0200 Subject: [PATCH] Add IncludeError exception and use it in CI config --- lib/gitlab/ci/config.rb | 6 +++--- lib/gitlab/ci/config/external/processor.rb | 3 ++- spec/lib/gitlab/ci/config_spec.rb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 7b3c5c12c61..fedaf18ef30 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -13,10 +13,10 @@ module Gitlab @global = Entry::Global.new(@config) @global.compose! - rescue Loader::FormatError, Extendable::ExtensionError => e + rescue Loader::FormatError, + Extendable::ExtensionError, + External::Processor::IncludeError => e raise Config::ConfigError, e.message - rescue External::Processor::FileError => e - raise ::Gitlab::Ci::YamlProcessor::ValidationError, e.message end def valid? diff --git a/lib/gitlab/ci/config/external/processor.rb b/lib/gitlab/ci/config/external/processor.rb index f3b20085cd6..32890f84de9 100644 --- a/lib/gitlab/ci/config/external/processor.rb +++ b/lib/gitlab/ci/config/external/processor.rb @@ -5,7 +5,8 @@ module Gitlab class Config module External class Processor - FileError = Class.new(StandardError) + IncludeError = Class.new(StandardError) + FileError = Class.new(IncludeError) def initialize(values, project, sha) @values = values diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb index 7a749a2ef6d..8925b17be58 100644 --- a/spec/lib/gitlab/ci/config_spec.rb +++ b/spec/lib/gitlab/ci/config_spec.rb @@ -200,7 +200,7 @@ describe Gitlab::Ci::Config do it 'raises error YamlProcessor validationError' do expect { config }.to raise_error( - ::Gitlab::Ci::YamlProcessor::ValidationError, + described_class::ConfigError, "Local file 'invalid' is not valid." ) end