class Win32::Registry::Error - Documentation for Ruby 4.0
Description: class Win32::Registry::Error: Error
Keywords: ruby,class,Win32::Registry::Error

🔍

No recent searches

# class Win32::Registry::Error

`Error`

### Attributes

code [R]

`Win32` `API` error code.

### Public Class Methods

new (code)
Source

    # File ext/win32/lib/win32/registry.rb, line 174
    def initialize(code)
      @code = code
      buff = WCHAR_NUL * 1024
      lang = 0
      begin
        len = FormatMessageW.call(0x1200, nil, code, lang, buff, 1024, nil)
        msg = buff.byteslice(0, len * WCHAR_SIZE)
        msg.delete!(WCHAR_CR)
        msg.chomp!
        msg.encode!(LOCALE)
      rescue EncodingError
        raise unless lang == 0
        lang = 0x0409         # en_US
        retry
      end
      super msg
    end

new(code) -> error object

Initializes the message for `Win32` `API` error `code`.

Calls superclass method `Exception::new`