From 641cba8c2d8727b18571f513b600b8bc4879c572 Mon Sep 17 00:00:00 2001 From: Ian Kronquist Date: Thu, 16 Jul 2015 13:28:04 -0700 Subject: [PATCH] (maint) Improve message when type error is raised Addresses @hlindberg's comment after PR #35 was closed. Use the error message from the exception which is actually exactly what I wanted to say anyway. --- .../puppetlabs/strings/yard/handlers/host_class_handler.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb b/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb index 8c972ed..06d4a65 100644 --- a/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb +++ b/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb @@ -13,14 +13,13 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::HostClassHandler < PuppetX:: statement.pops_obj.parameters.each do |pop_param| # If the parameter's type expression is nil, default to Any if pop_param.type_expr == nil - param_type_info[pop_param.name] = Puppet::Pops::Types::TypeFactory.any() + param_type_info[pop_param.name] = Puppet::Pops::Types::TypeFactory.any() else begin param_type_info[pop_param.name] = tp.interpret_any(pop_param.type_expr) - rescue Puppet::ParseError + rescue Puppet::ParseError => e # If the type could not be interpreted insert a prominent warning - param_type_info[pop_param.name] = "TypeError - " + - "#{pop_param.type_expr} isn't a valid type." + param_type_info[pop_param.name] = "Type Error: #{e.message}" end end end