diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-07-29 15:38:45 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-07-29 15:38:45 -0700 |
commit | 3519f13ad7cb7bb582198185cb0bc470330fb866 (patch) | |
tree | 8352dd0f0b1303b6dbc7ca3ca72bb174aca48415 /lib/chef/exceptions.rb | |
parent | 66146d5352fd59b8e1f81370e40004f423a55699 (diff) | |
download | chef-3519f13ad7cb7bb582198185cb0bc470330fb866.tar.gz |
Add Win32NetAPIError exception class
Diffstat (limited to 'lib/chef/exceptions.rb')
-rw-r--r-- | lib/chef/exceptions.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index e2e36e8162..1e0b83d7b8 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -126,6 +126,23 @@ class Chef class EnclosingDirectoryDoesNotExist < ArgumentError; end # Errors originating from calls to the Win32 API class Win32APIError < RuntimeError; end + + class Win32NetAPIError < Win32APIError + attr_reader :msg, :error_code + def initialize(msg, error_code) + @msg = msg + @error_code = error_code + + formatted_message = "" + formatted_message << "---- Begin Win32 API output ----\n" + formatted_message << "Net Api Error Code: #{error_code}\n" + formatted_message << "Net Api Error Message: #{msg}\n" + formatted_message << "---- End Win32 API output ----\n" + + super(formatted_message) + end + end + # Thrown when Win32 API layer binds to non-existent Win32 function. Occurs # when older versions of Windows don't support newer Win32 API functions. class Win32APIFunctionNotImplemented < NotImplementedError; end |