Permalink
Browse files

added user-friendly error message for config.yml errors

  • Loading branch information...
1 parent 00054f1 commit 94727555e8c00f538bee82e8067d782498569f00 @mholling committed Feb 15, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 nswtopo.rb
View
11 nswtopo.rb
@@ -1380,9 +1380,14 @@ def self.build(map_name, bounds, projection, scaling, image_path, kmz_path)
def self.run
output_dir = Dir.pwd
- config = YAML.load(CONFIG)
- config["controls"]["file"] ||= "controls.gpx" if File.exists?(File.join(output_dir, "controls.gpx"))
- config = config.deep_merge YAML.load(File.open(File.join(output_dir, "config.yml")))
+ default_config = YAML.load(CONFIG)
+ default_config["controls"]["file"] ||= "controls.gpx" if File.exists?(File.join(output_dir, "controls.gpx"))
+ user_config = begin
+ YAML.load File.open(File.join(output_dir, "config.yml"))
+ rescue ArgumentError, SyntaxError => e
+ abort "Error in configuration file: #{e.message}"
+ end
+ config = default_config.deep_merge user_config
config["exclude"] = [ *config["exclude"] ]
config["formats"].each(&:downcase!)
{

0 comments on commit 9472755

Please sign in to comment.