Skip to content

Commit b8f3f10

Browse files
committed
Raise more specific, informational exceptions
1 parent 91e594f commit b8f3f10

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/octocatalog-diff/util/catalogs.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def build_catalog_parallelizer
105105
if failures.any?
106106
f = failures.reject { |r| r.exception.is_a?(OctocatalogDiff::Util::Parallel::IncompleteTask) }.first
107107
f ||= failures.first
108-
raise OctocatalogDiff::Errors::CatalogError, "#{f.exception.class}: #{f.exception.message}"
108+
raise f.exception
109109
end
110110

111111
# Construct result hash. Will eventually be in the format
@@ -239,14 +239,16 @@ def build_catalog(opts, logger = @logger)
239239
end
240240

241241
# Validate a catalog in the parallel execution
242+
# The catalog validator can raise an exception to cause a more specific error message or
243+
# use a different class of exception than the default one here.
242244
# @param catalog [OctocatalogDiff::Catalog] Catalog object
243245
# @param logger [Logger] Logger object (presently unused)
244246
# @param args [Hash] Additional arguments set specifically for validator
245247
def catalog_validator(catalog = nil, _logger = @logger, args = {})
246248
return false unless catalog.is_a?(OctocatalogDiff::Catalog)
247249
catalog.validate_references if args[:task] == :to
248250
return true if catalog.valid?
249-
raise OctocatalogDiff::Errors::CatalogError, 'Catalog failed: Invalid catalog'
251+
raise OctocatalogDiff::Errors::CatalogError, "Catalog failed: #{catalog.error_message}"
250252
end
251253
end
252254
end

0 commit comments

Comments
 (0)