module FFI
Public Class Methods
Source
# File lib/ffi/win32/extensions.rb, line 100 def raise_windows_error(function, err = FFI.errno) raise SystemCallError.new(windows_error_message(function, err), err) end
Raises a Windows specific error using SystemCallError that is based on the err
provided, with the message prepended with the function
name.
Source
# File lib/ffi/win32/extensions.rb, line 80 def windows_error_message(function, err = FFI.errno) error_message = "" # ARGUMENT_ARRAY + SYSTEM + MAX_WIDTH_MASK flags = 0x00001000 | 0x00000200 | 0x000000FF # 0x0409 = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) # We use English for errors because Ruby uses English for errors. FFI::MemoryPointer.new(:char, 1024) do |buf| length = FormatMessage(flags, nil, err , 0x0409, buf, buf.size, nil) error_message = function + ": " + buf.read_string(length).strip end error_message end
Returns a Windows specific error message based on err
prepended with the function
name. Note that this does not actually raise an error, it only returns the message.
The message will always be English regardless of your locale.
Private Instance Methods
Source
# File lib/ffi/win32/extensions.rb, line 100 def raise_windows_error(function, err = FFI.errno) raise SystemCallError.new(windows_error_message(function, err), err) end
Raises a Windows specific error using SystemCallError that is based on the err
provided, with the message prepended with the function
name.
Source
# File lib/ffi/win32/extensions.rb, line 80 def windows_error_message(function, err = FFI.errno) error_message = "" # ARGUMENT_ARRAY + SYSTEM + MAX_WIDTH_MASK flags = 0x00001000 | 0x00000200 | 0x000000FF # 0x0409 = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) # We use English for errors because Ruby uses English for errors. FFI::MemoryPointer.new(:char, 1024) do |buf| length = FormatMessage(flags, nil, err , 0x0409, buf, buf.size, nil) error_message = function + ": " + buf.read_string(length).strip end error_message end
Returns a Windows specific error message based on err
prepended with the function
name. Note that this does not actually raise an error, it only returns the message.
The message will always be English regardless of your locale.