Method: ReservedNames::Win32::Error.raise!

Defined in:
lib/chef/win32/error.rb

.raise!(message = nil) ⇒ Object

Raises the last error. This should only be called by Win32 API wrapper functions, and then only when wrapped in an if() statement (since it unconditionally exits)

Returns

nil:

always returns nil when it does not raise

Raises

Chef::Exceptions::Win32APIError:


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/chef/win32/error.rb', line 60

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
end