Skip to content

Commit

Permalink
add some error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
roobert committed Aug 11, 2017
1 parent a338f0e commit cff74a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
dir:
input: templates
output: output/stage

17 changes: 15 additions & 2 deletions lib/erb-hiera.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def self.run
in_dir = config["dir"]["input"]
out_dir = config["dir"]["output"]

[in_dir, out_dir].each do |dir|
raise StandardError, "error: undefined #{dir.split('_')[0]} dir" unless dir
[:in_dir, :out_dir].each do |dir|
raise StandardError, "error: undefined #{dir.to_s.split('_')[0]}put directory" unless binding.local_variable_get(dir)
end

manifests(in_dir).each do |manifest|
Expand All @@ -42,10 +42,23 @@ def self.run
end
end
end
rescue => error
handle_error(error)
exit 1
end

private

def self.handle_error(error)
if options[:debug]
puts
puts error.backtrace
end

puts
puts error
end

def self.mappings
YAML.load_file(options[:config])
end
Expand Down

0 comments on commit cff74a6

Please sign in to comment.