From 6e57727eeac51c085670eb08dc2065706ef0f680 Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 31 Mar 2013 14:14:37 -0700 Subject: better error messages when json or node parsing goes wrong. --- lib/leap_cli/config/manager.rb | 2 +- lib/leap_cli/util.rb | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index cf4d127..f5282c5 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -199,7 +199,7 @@ module LeapCli # parse json begin hash = JSON.parse(buffer.string, :object_class => Hash, :array_class => Array) || {} - rescue SyntaxError => exc + rescue SyntaxError, JSON::ParserError => exc log 0, :error, 'in file "%s":' % filename log 0, exc.to_s, :indent => 1 return nil diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb index 0453b6d..b2a1dcf 100644 --- a/lib/leap_cli/util.rb +++ b/lib/leap_cli/util.rb @@ -111,13 +111,14 @@ module LeapCli def assert_config!(conf_path) value = nil - #begin + begin value = manager.instance_eval(conf_path) #rescue NoMethodError #rescue NameError - #end - assert! !value.nil? && value != "REQUIRED" do - log :missing, "required configuration value for #{conf_path}" + ensure + assert! !value.nil? && value != "REQUIRED" do + log :missing, "required configuration value for #{conf_path}" + end end end -- cgit v1.2.3