Class: LLDB::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/lldb/error.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr = nil) ⇒ Error

Returns a new instance of Error.

RBS:

  • ptr: FFI::Pointer?

  • return: void



51
52
53
54
# File 'lib/lldb/error.rb', line 51

def initialize(ptr = nil)
  @ptr = ptr || FFIBindings.lldb_error_create
  ObjectSpace.define_finalizer(self, self.class.release(@ptr))
end

Class Method Details

.release(ptr) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • return: ^(Integer) -> void



58
59
60
# File 'lib/lldb/error.rb', line 58

def self.release(ptr)
  ->(_id) { FFIBindings.lldb_error_destroy(ptr) unless ptr.null? }
end

Instance Method Details

#clearObject

RBS:

  • return: void



97
98
99
# File 'lib/lldb/error.rb', line 97

def clear
  FFIBindings.lldb_error_clear(@ptr)
end

#codeObject Also known as: error_code

RBS:

  • return: Integer



80
81
82
# File 'lib/lldb/error.rb', line 80

def code
  FFIBindings.lldb_error_get_error(@ptr)
end

#fail?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


68
69
70
# File 'lib/lldb/error.rb', line 68

def fail?
  FFIBindings.lldb_error_fail(@ptr) != 0
end

#messageObject Also known as: to_s

RBS:

  • return: String



73
74
75
# File 'lib/lldb/error.rb', line 73

def message
  FFIBindings.lldb_error_get_cstring(@ptr) || ''
end

#raise_if_error!(operation = 'native operation') ⇒ Object

RBS:

  • operation: String

  • return: void

Raises:



114
115
116
# File 'lib/lldb/error.rb', line 114

def raise_if_error!(operation = 'native operation')
  raise OperationError.new(operation, self) if fail?
end

#set_error(message) ⇒ Object

RBS:

  • message: String

  • return: void



103
104
105
# File 'lib/lldb/error.rb', line 103

def set_error(message)
  FFIBindings.lldb_error_set_error_string(@ptr, message)
end

#success?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


63
64
65
# File 'lib/lldb/error.rb', line 63

def success?
  FFIBindings.lldb_error_success(@ptr) != 0
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



108
109
110
# File 'lib/lldb/error.rb', line 108

def to_ptr
  @ptr
end

#typeObject

RBS:

  • return: Integer



87
88
89
# File 'lib/lldb/error.rb', line 87

def type
  FFIBindings.lldb_error_get_type(@ptr)
end

#type_nameObject

RBS:

  • return: String



92
93
94
# File 'lib/lldb/error.rb', line 92

def type_name
  ErrorType::NAMES.fetch(type, 'unknown')
end