Class: XlibObj::Error
- Inherits:
-
Object
- Object
- XlibObj::Error
- Defined in:
- lib/error.rb
Instance Method Summary collapse
- #code ⇒ Object
- #code_description ⇒ Object
- #description ⇒ Object
- #general_description ⇒ Object
-
#initialize(display, error) ⇒ Error
constructor
A new instance of Error.
- #minor_code ⇒ Object
- #minor_code_description ⇒ Object
- #request ⇒ Object
- #resource ⇒ Object
- #resource_description ⇒ Object
Constructor Details
#initialize(display, error) ⇒ Error
Returns a new instance of Error.
11 12 13 14 |
# File 'lib/error.rb', line 11 def initialize(display, error) @display = display @error = error end |
Instance Method Details
#code ⇒ Object
16 17 18 |
# File 'lib/error.rb', line 16 def code @error[:error_code] end |
#code_description ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/error.rb', line 52 def code_description = 2**16 = FFI::MemoryPointer.new(:char, ) Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, 'MajorCode', 'Request Major code %d', , ) .read_string.gsub('%d', code.to_s) end |
#description ⇒ Object
32 33 34 35 36 37 |
# File 'lib/error.rb', line 32 def description "#{general_description}\n" << " #{code_description}\n" << ((code >= 128) ? " #{minor_code_description}\n" : "") << " #{resource_description}" end |
#general_description ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/error.rb', line 39 def general_description type_size = 2**16 type = FFI::MemoryPointer.new(:char, type_size) Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, 'XError', 'X Error', type, type_size) details_size = 2**16 details = FFI::MemoryPointer.new(:char, details_size) Xlib.XGetErrorText(@display.to_native, code, details, details_size) "#{type.read_string}: #{details.read_string}" end |
#minor_code ⇒ Object
20 21 22 |
# File 'lib/error.rb', line 20 def minor_code @error[:minor_code] end |
#minor_code_description ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/error.rb', line 60 def minor_code_description = 2**16 = FFI::MemoryPointer.new(:char, ) Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, 'MinorCode', 'Request Minor code %d', , ) .read_string.gsub('%d', minor_code.to_s) end |
#request ⇒ Object
24 25 26 |
# File 'lib/error.rb', line 24 def request @error[:request_code] end |
#resource ⇒ Object
28 29 30 |
# File 'lib/error.rb', line 28 def resource @error[:resourceid] end |
#resource_description ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/error.rb', line 68 def resource_description = 2**16 = FFI::MemoryPointer.new(:char, ) if [Xlib::BadWindow, Xlib::BadPixmap, Xlib::BadCursor, Xlib::BadFont, Xlib::BadDrawable, Xlib::BadColor, Xlib::BadGC, Xlib::BadIDChoice].include?(code) Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, "ResourceID", "ResourceID %x", , ) elsif code == Xlib::BadValue Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, "Value", "Value 0x%x", , ) elsif code == Xlib::BadAtom Xlib.XGetErrorDatabaseText(@display.to_native, @display.name, "AtomID", "AtomID 0x%x", , ) end .read_string.gsub('%x', resource.to_s) end |