Skip to content

Commit 4a1ce11

Browse files
committed
(FM-7696) remove overzealous exception handling
1 parent b6cbdcf commit 4a1ce11

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/puppet/resource_api/transport.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ def register(schema)
2121

2222
def connect(name, connection_info)
2323
validate(name, connection_info)
24-
begin
25-
require "puppet/transport/#{name}"
26-
class_name = name.split('_').map { |e| e.capitalize }.join
27-
Puppet::Transport.const_get(class_name).new(connection_info)
28-
rescue LoadError, NameError => detail
29-
raise Puppet::DevError, 'Cannot load transport for `%{target}`: %{detail}' % { target: name, detail: detail }
30-
end
24+
require "puppet/transport/#{name}"
25+
class_name = name.split('_').map { |e| e.capitalize }.join
26+
Puppet::Transport.const_get(class_name).new(connection_info)
3127
end
3228
module_function :connect # rubocop:disable Style/AccessModifierDeclarations
3329

spec/puppet/resource_api/transport_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@
104104
context 'when the transport file does not exist' do
105105
it 'throws a DevError' do
106106
expect(described_class).to receive(:validate).with(name, connection_info)
107-
expect { described_class.connect(name, connection_info) }.to raise_error Puppet::DevError,
108-
%r{Cannot load transport for `test_target`}
107+
expect { described_class.connect(name, connection_info) }.to raise_error LoadError, %r{(no such file to load|cannot load such file) -- puppet/transport/test_target}
109108
end
110109
end
111110

@@ -114,7 +113,7 @@
114113
it 'throws a DevError' do
115114
expect(described_class).to receive(:validate).with(name, connection_info)
116115
expect(described_class).to receive(:require).with('puppet/transport/test_target')
117-
expect { described_class.connect(name, connection_info) }.to raise_error Puppet::DevError,
116+
expect { described_class.connect(name, connection_info) }.to raise_error NameError,
118117
%r{uninitialized constant (Puppet::Transport|TestTarget)}
119118
end
120119
end

0 commit comments

Comments
 (0)