lib/puppet-debugger/support/scope.rb in puppet-debugger-0.19.0 vs lib/puppet-debugger/support/scope.rb in puppet-debugger-1.0.0

- old
+ new

@@ -10,30 +10,32 @@ def catalog @catalog || scope.compiler.catalog end - def get_catalog_text(c) - return nil unless c - Puppet::FileSystem.read(c, :encoding => 'utf-8') + def get_catalog_text(catalog) + return nil unless catalog + + Puppet::FileSystem.read(catalog, encoding: 'utf-8') end def set_catalog(catalog_file) - return unless catalog_file - catalog_text = get_catalog_text(catalog_file) - scope # required - Puppet.override({:current_environment => environment}, _("For puppet debugger")) do - format = Puppet::Resource::Catalog.default_format - begin - c = Puppet::Resource::Catalog.convert_from(format, catalog_text) - rescue => detail - raise Puppet::Error, _("Could not deserialize catalog from %{format}: %{detail}") % { format: format, detail: detail }, detail.backtrace - end - # Resolve all deferred values and replace them / mutate the catalog - # Puppet 6 only - Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(node.facts, c) if Gem::Version.new(Puppet.version) >= Gem::Version.new('6.0.0') - @catalog = c + return unless catalog_file + + catalog_text = get_catalog_text(catalog_file) + scope # required + Puppet.override({ current_environment: environment }, _('For puppet debugger')) do + format = Puppet::Resource::Catalog.default_format + begin + c = Puppet::Resource::Catalog.convert_from(format, catalog_text) + rescue StandardError => e + raise Puppet::Error, format(_('Could not deserialize catalog from %{format}: %{detail}'), format: format, detail: e), e.backtrace end + # Resolve all deferred values and replace them / mutate the catalog + # Puppet 6 only + Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(node.facts, c) if Gem::Version.new(Puppet.version) >= Gem::Version.new('6.0.0') + @catalog = c + end end # @return [Puppet::Pops::Scope] - returns a puppet scope object def scope @scope ||= create_scope