From 00962c7c2a4ef3c1e0cc89044efcf62be2461b43 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Apr 2014 18:00:33 -0700 Subject: [PATCH] commands/box/repackage: better error if box not found --- lib/vagrant/errors.rb | 4 ++++ plugins/commands/box/command/repackage.rb | 7 ++++--- templates/locales/en.yml | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 754b29a73..ca0a0b9bf 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -192,6 +192,10 @@ module Vagrant error_key(:box_not_found_with_provider) end + class BoxNotFoundWithProviderAndVersion < VagrantError + error_key(:box_not_found_with_provider_and_version) + end + class BoxProviderDoesntMatch < VagrantError error_key(:box_provider_doesnt_match) end diff --git a/plugins/commands/box/command/repackage.rb b/plugins/commands/box/command/repackage.rb index 545a3d4d4..a8df09159 100644 --- a/plugins/commands/box/command/repackage.rb +++ b/plugins/commands/box/command/repackage.rb @@ -23,9 +23,10 @@ module VagrantPlugins # Verify the box exists that we want to repackage box = @env.boxes.find(box_name, box_provider, "= #{box_version}") if !box - raise Vagrant::Errors::BoxNotFound, - :name => box_name, - :provider => box_provider + raise Vagrant::Errors::BoxNotFoundWithProviderAndVersion, + name: box_name, + provider: box_provider.to_s, + version: box_version end # Repackage the box diff --git a/templates/locales/en.yml b/templates/locales/en.yml index dae427750..36b833a29 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -443,6 +443,10 @@ en: the box are shown below: %{providers} + box_not_found_with_provider_and_version: |- + The box '%{name}' (v%{version}) with provider '%{provider}' + could not be found. Please double check and try again. You + can see all the boxes that are installed with `vagrant box list`. box_provider_doesnt_match: |- The box you attempted to add doesn't match the provider you specified.