diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-05 10:17:13 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-05 10:19:35 +0200 |
commit | b83fa58f063b0b086b2c4def68835dbec4fd6bcd (patch) | |
tree | 8f2da6f5e94c7ea8093a025499313832c0457fa3 | |
parent | d7133d946c0ecd13a2f5be723ccb541f37b8c1f2 (diff) | |
download | gitlab-ce-b83fa58f063b0b086b2c4def68835dbec4fd6bcd.tar.gz |
Improve extended CI/CD config error messages
-rw-r--r-- | lib/gitlab/ci/config/extendable/entry.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/extendable/entry_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 2 |
4 files changed, 13 insertions, 11 deletions
diff --git a/lib/gitlab/ci/config/extendable/entry.rb b/lib/gitlab/ci/config/extendable/entry.rb index 9bcb0e2c784..f9b258590d9 100644 --- a/lib/gitlab/ci/config/extendable/entry.rb +++ b/lib/gitlab/ci/config/extendable/entry.rb @@ -3,12 +3,12 @@ module Gitlab class Config class Extendable class Entry - MAX_NESTING_LEVELS = 10 - InvalidExtensionError = Class.new(Extendable::ExtensionError) CircularDependencyError = Class.new(Extendable::ExtensionError) NestingTooDeepError = Class.new(Extendable::ExtensionError) + MAX_NESTING_LEVELS = 10 + attr_reader :key def initialize(key, context, parent = nil) @@ -48,22 +48,22 @@ module Gitlab if unknown_extension? raise Entry::InvalidExtensionError, - "Unknown extends key in extended `#{key}`!" + "#{key}: unknown `extends` key" end if invalid_base? raise Entry::InvalidExtensionError, - "Invalid base hash in extended `#{key}`!" + "#{key}: invalid base hash in `extends`" end if nesting_too_deep? raise Entry::NestingTooDeepError, - "`extends` nesting too deep in `#{key}`!" + "#{key}: `extends` nesting too deep" end if circular_dependency? raise Entry::CircularDependencyError, - "Circular dependency detected in extended `#{key}`!" + "#{key}: circular dependency detected in `extends`" end @context[key] = base_hash!.deep_merge(value) diff --git a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb index 86a3d13ee97..e05bd22ebd0 100644 --- a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb @@ -126,7 +126,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do it 'raises an error' do expect { subject.extend! } - .to raise_error(StandardError, /Invalid base hash/) + .to raise_error(described_class::InvalidExtensionError, + /invalid base hash/) end end @@ -137,7 +138,8 @@ describe Gitlab::Ci::Config::Extendable::Entry do it 'raises an error' do expect { subject.extend! } - .to raise_error(StandardError, /Unknown extends key/) + .to raise_error(described_class::InvalidExtensionError, + /unknown `extends` key/) end end @@ -199,7 +201,7 @@ describe Gitlab::Ci::Config::Extendable::Entry do it 'raises an error' do expect { subject.extend! } .to raise_error(described_class::CircularDependencyError, - /Circular dependency detected/) + /circular dependency detected/) end end diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb index ac3edbd22e3..5a78ce783dd 100644 --- a/spec/lib/gitlab/ci/config_spec.rb +++ b/spec/lib/gitlab/ci/config_spec.rb @@ -119,7 +119,7 @@ describe Gitlab::Ci::Config do it 'raises an error' do expect { config }.to raise_error( - described_class::ConfigError, /Circular dependency detected/ + described_class::ConfigError, /circular dependency detected/ ) end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index d406a3d7409..a75c8246758 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1367,7 +1367,7 @@ module Gitlab expect { Gitlab::Ci::YamlProcessor.new(config) } .to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, - 'Unknown extends key in extended `rspec`!') + 'rspec: unknown `extends` key') end end |