Skip to content

Commit 7a1ebe7

Browse files
committed
(#1532) Replace ParserError with Puppet::Error
I'm not sure how we ended up with ParserError in the provider. This exception doesn't exist in Ruby. Puppet ships ther own exception, Puppet::Error. It probably makes sense to raise that instead. Fixes 179472b
1 parent d4560c1 commit 7a1ebe7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/puppet/provider/postgresql_conf/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def write_config(file, lines)
7575
# check, if resource exists in postgresql.conf file
7676
def exists?
7777
select = parse_config.select { |hash| hash[:key] == resource[:key] }
78-
raise ParserError, "found multiple config items of #{resource[:key]} found, please fix this" if select.length > 1
78+
raise Puppet::Error, "found multiple config items of #{resource[:key]} found, please fix this" if select.length > 1
7979
return false if select.empty?
8080

8181
@result = select.first

spec/unit/provider/postgresql_conf/ruby_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
expect(provider).to respond_to(:exists?)
3131
end
3232

33+
describe 'duplicate keys in postgresql.conf' do
34+
it 'raises an exception' do
35+
allow(provider).to receive(:parse_config).and_return([{ key: 'foo', line: 1 }, { key: 'foo', line: 2 }])
36+
expect { provider.exists? }.to raise_error(Puppet::Error, 'found multiple config items of foo found, please fix this')
37+
end
38+
end
39+
3340
it 'has a method create' do
3441
expect(provider).to respond_to(:create)
3542
end

0 commit comments

Comments
 (0)