summaryrefslogtreecommitdiff
path: root/lib/chef/win32/error.rb
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2016-02-03 09:58:18 -0800
committerMatt Wrock <matt@mattwrock.com>2016-02-03 09:58:18 -0800
commitb74d0028914b03bce785b940f0cad5390444ae3a (patch)
treebf1e75773bae697cd469f5e560440e2fd0b5e1c5 /lib/chef/win32/error.rb
parentab63cd4be967b5d01f6ec856244e4b9af4e896d9 (diff)
downloadchef-invalid.tar.gz
fixes #4515 and use FormatMessage to get correct error messages from native API instead of retyping them with our fingersinvalid
Diffstat (limited to 'lib/chef/win32/error.rb')
-rw-r--r--lib/chef/win32/error.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/chef/win32/error.rb b/lib/chef/win32/error.rb
index 1b3c104e85..8c3ff2f08f 100644
--- a/lib/chef/win32/error.rb
+++ b/lib/chef/win32/error.rb
@@ -59,13 +59,17 @@ class Chef
# Chef::Exceptions::Win32APIError:::
def self.raise!(message = nil, code = get_last_error)
msg = format_message(code).strip
- formatted_message = ""
- formatted_message << message if message
- formatted_message << "---- Begin Win32 API output ----\n"
- formatted_message << "System Error Code: #{code}\n"
- formatted_message << "System Error Message: #{msg}\n"
- formatted_message << "---- End Win32 API output ----\n"
- raise Chef::Exceptions::Win32APIError, msg + "\n" + formatted_message
+ if code == ERROR_USER_NOT_FOUND
+ raise Chef::Exceptions::UserIDNotFound, msg
+ else
+ formatted_message = ""
+ formatted_message << message if message
+ formatted_message << "---- Begin Win32 API output ----\n"
+ formatted_message << "System Error Code: #{code}\n"
+ formatted_message << "System Error Message: #{msg}\n"
+ formatted_message << "---- End Win32 API output ----\n"
+ raise Chef::Exceptions::Win32APIError, msg + "\n" + formatted_message
+ end
end
end
end