Skip to content

Commit abcf875

Browse files
committed
Wrap broken source file as a catalog error
1 parent d6646f2 commit abcf875

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/octocatalog-diff/catalog-util/fileresources.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ def self._convert_file_resources(resources, compilation_dir, environment = 'prod
8686
resources.map! do |resource|
8787
if resource_convertible?(resource)
8888
path = file_path(resource['parameters']['source'], modulepaths)
89-
raise Errno::ENOENT, "Unable to resolve '#{resource['parameters']['source']}'!" if path.nil?
89+
if path.nil?
90+
# Pass this through as a wrapped exception, because it's more likely to be something wrong
91+
# in the catalog itself than it is to be a broken setup of octocatalog-diff.
92+
message = "Errno::ENOENT: Unable to resolve '#{resource['parameters']['source']}'!"
93+
raise OctocatalogDiff::Errors::CatalogError, message
94+
end
9095

9196
if File.file?(path)
9297
# If the file is found, read its content. If the content is all ASCII, substitute it into

spec/octocatalog-diff/integration/convert_file_resources_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
)
161161
expect(result[:exitcode]).to eq(-1)
162162
expect(result[:exception]).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
163-
expect(result[:exception].message).to match(/Errno::ENOENT: No such file or directory/)
163+
expect(result[:exception].message).to match(/Errno::ENOENT/)
164164
expect(result[:exception].message).to match(%r{Unable to resolve 'puppet:///modules/test/foo-new'})
165165
end
166166
end

0 commit comments

Comments
 (0)