Exception: Fontina::Windows::Win32::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Fontina::Windows::Win32::Error
- Defined in:
- lib/fontina/windows/win32/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
- .check(code) ⇒ Object
- .check_hr(code) ⇒ Object
- .check_last ⇒ Object
- .clear ⇒ Object
- .raise_last ⇒ Object
Instance Method Summary collapse
-
#initialize(code) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
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
#code ⇒ Object (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_last ⇒ Object
23 24 25 |
# File 'lib/fontina/windows/win32/error.rb', line 23 def check_last check Kernel32.GetLastError() end |
.clear ⇒ Object
35 36 37 |
# File 'lib/fontina/windows/win32/error.rb', line 35 def clear Kernel32.SetLastError(ERROR_SUCCESS) end |
.raise_last ⇒ Object
19 20 21 |
# File 'lib/fontina/windows/win32/error.rb', line 19 def raise_last raise new Kernel32.GetLastError() end |
Instance Method Details
#to_s ⇒ Object
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 |