diff --git a/plugins/hosts/windows/cap/smb.rb b/plugins/hosts/windows/cap/smb.rb index 9287957bb..d224e06a3 100644 --- a/plugins/hosts/windows/cap/smb.rb +++ b/plugins/hosts/windows/cap/smb.rb @@ -64,7 +64,10 @@ module VagrantPlugins # Check if this name is already in use if share_info = current_shares[data[:smb_id]] if !hostpath.empty? && share_info["Path"].downcase != hostpath.downcase - raise "share in use with different path" + raise SyncedFolderSMB::Errors::SMBNameError, + path: hostpath, + existing_path: share_info["Path"], + name: data[:smb_id] end @@logger.info("skip creation of existing share name=#{name} id=#{data[:smb_id]}") next @@ -98,7 +101,7 @@ module VagrantPlugins def self.existing_shares result = Vagrant::Util::PowerShell.execute_cmd("Get-SmbShare|Format-List") if result.nil? - raise "failed to get existing shares" + raise SyncedFolderSMB::Errors::SMBListFailed end shares = {} name = nil diff --git a/plugins/synced_folders/smb/errors.rb b/plugins/synced_folders/smb/errors.rb index ebb9bbef3..761924207 100644 --- a/plugins/synced_folders/smb/errors.rb +++ b/plugins/synced_folders/smb/errors.rb @@ -18,6 +18,14 @@ module VagrantPlugins error_key(:credentials_missing) end + class SMBListFailed < SMBError + error_key(:list_failed) + end + + class SMBNameError < SMBError + error_key(:name_error) + end + class DefineShareFailed < SMBError error_key(:define_share_failed) end diff --git a/templates/locales/synced_folder_smb.yml b/templates/locales/synced_folder_smb.yml index 79eb93aef..3521ff4ff 100644 --- a/templates/locales/synced_folder_smb.yml +++ b/templates/locales/synced_folder_smb.yml @@ -55,6 +55,18 @@ en: Stderr: %{stderr} Stdout: %{stdout} + name_error: |- + Vagrant is unable to setup a requested SMB share. An SMB share already + exists with the given name. + + Share name: %{name} + + Current path: %{existing_path} + + Requested path: %{path} + list_failed: |- + Vagrant failed to generate a list of local SMB shares. Please try + running the command again. no_routable_host_addr: |- We couldn't detect an IP address that was routable to this machine from the guest machine! Please verify networking is properly