Exception: Fontina::Windows::Win32::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/fontina/windows/win32/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Error

Returns a new instance of Error.



6
7
8
# File 'lib/fontina/windows/win32/error.rb', line 6

def initialize(code)
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/fontina/windows/win32/error.rb', line 4

def code
  @code
end

Class Method Details

.check(code) ⇒ Object



27
28
29
# File 'lib/fontina/windows/win32/error.rb', line 27

def check(code)
  raise new code unless ERROR_SUCCESS == code
end

.check_hr(code) ⇒ Object



31
32
33
# File 'lib/fontina/windows/win32/error.rb', line 31

def check_hr(code)
  raise new code unless 0 == code[31]
end

.check_lastObject



23
24
25
# File 'lib/fontina/windows/win32/error.rb', line 23

def check_last
  check Kernel32.GetLastError()
end

.clearObject



35
36
37
# File 'lib/fontina/windows/win32/error.rb', line 35

def clear
  Kernel32.SetLastError(ERROR_SUCCESS)
end

.raise_lastObject



19
20
21
# File 'lib/fontina/windows/win32/error.rb', line 19

def raise_last
  raise new Kernel32.GetLastError()
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
# File 'lib/fontina/windows/win32/error.rb', line 10

def to_s
  @message ||= begin
    Kernel32.FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, code, 1024).rstrip
  rescue Error
    '0x%04x' % code
  end
end