Permalink
Browse files

Capture exceptions when installing gems.

If a gem does not exist (if the user misspelled the name) and we try to
install it, RubyGems will raise an incomprehensible error. This patch captures
exceptions and prints something understable out to the user.

Closes #31
  • Loading branch information...
1 parent 571adcd commit 3687cd379263b91cf379457ea072281bc1fda00e @TwP committed May 8, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/bones/plugins/gem.rb
View
@@ -284,7 +284,13 @@ def define_tasks
end
$stdout.puts "Installing #{dep.name}"
- installer.install dep
+ begin
+ installer.install dep
+ rescue
+ $stdout.puts(' '+Bones::Colors.colorize("Could not install #{dep.name}!", :white, :on_red))
+ $stdout.puts(' '+Bones::Colors.colorize("The gem does not appear to exist in any known repository.", :cyan))
+ next
+ end
installer.installed_gems.each {|spec|
$stdout.puts "Successfully installed #{spec.full_name}"
}

0 comments on commit 3687cd3

Please sign in to comment.