summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user/windows.rb
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2014-08-22 15:31:03 -0400
committerBryan McLellan <btm@loftninjas.org>2014-08-22 19:07:23 -0400
commitec0ff9515757443b07a50a412a0a9b70a68de689 (patch)
tree3deb50d7dc540ac16a2465b6a96eb964b6585a89 /lib/chef/provider/user/windows.rb
parentb82a5272ec6798cf26bcf9feaf39faae451b574d (diff)
downloadchef-ec0ff9515757443b07a50a412a0a9b70a68de689.tar.gz
Make exception for a user not existing more explicit
Diffstat (limited to 'lib/chef/provider/user/windows.rb')
-rw-r--r--lib/chef/provider/user/windows.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb
index 918c598774..66ef30c349 100644
--- a/lib/chef/provider/user/windows.rb
+++ b/lib/chef/provider/user/windows.rb
@@ -17,6 +17,7 @@
#
require 'chef/provider/user'
+require 'chef/exceptions'
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
require 'chef/util/windows/net_user'
end
@@ -37,17 +38,16 @@ class Chef
user_info = nil
begin
user_info = @net_user.get_info
- rescue
- @user_exists = false
- Chef::Log.debug("#{@new_resource} does not exist")
- end
- if user_info
@current_resource.uid(user_info[:user_id])
@current_resource.gid(user_info[:primary_group_id])
@current_resource.comment(user_info[:full_name])
@current_resource.home(user_info[:home_dir])
@current_resource.shell(user_info[:script_path])
+ rescue Chef::Exceptions::UserIDNotFound => e
+ # e.message should be "The user name could not be found" but checking for that could cause a localization bug
+ @user_exists = false
+ Chef::Log.debug("#{@new_resource} does not exist (#{e.message})")
end
@current_resource