Skip to content

Commit a2bc4b0

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.
1 parent d4560c1 commit a2bc4b0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-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/type/postgresql_conf_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
expect { described_class.new(name: 'foo.bar') }.not_to raise_error
2323
end
2424
end
25+
describe 'duplicate keys in postgresql.conf' do
26+
it 'raises an exception' do
27+
allow(described_class).to receive(:parse_config) { [{key: 'foo', line: 1}, {key: 'foo', line: 2}] }
28+
expect { described_class.new(name: 'foobar')}.to raise_error(Puppet::Error, %r{found multiple config items of foo found, please fix this})
29+
end
30+
end
2531

2632
describe 'when validating attributes' do
2733
[:name, :provider, :target].each do |param|

0 commit comments

Comments
 (0)