Permalink
Browse files

keys!: replace exception with explicit error message and exit()

This is less confusing when called from the CLI, since it doesn't
look like a ruby exception
  • Loading branch information...
pieter committed Jun 4, 2012
1 parent aa6109e commit 08c846df5b78025c43df3c1cf89e42e203e2575b
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/aws-keys.rb
View
@@ -37,10 +37,17 @@ def self.keys (type)
return
end
# Raises an exception if the keys can't be found
# Guaranteed to return a key, or exits the program
def self.keys! (type)
k = keys(type)
raise KeyNotFoundException.new("Could not find key of type: #{type}") unless k
unless k
STDERR.puts "Could not find key of type: #{type}"
STDERR.puts "Please make sure one of these files exists:"
PATHS.each { |p| STDERR.puts "* #{File.expand_path p}/#{type}.creds" }
exit 233
end
k
end
end

0 comments on commit 08c846d

Please sign in to comment.