Exception: PyBind::PyError
- Defined in:
- lib/pybind/error.rb
Instance Attribute Summary collapse
-
#traceback ⇒ Object
readonly
Returns the value of attribute traceback.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, value, traceback) ⇒ PyError
constructor
A new instance of PyError.
- #message ⇒ Object
Constructor Details
#initialize(type, value, traceback) ⇒ PyError
Returns a new instance of PyError.
16 17 18 19 20 21 |
# File 'lib/pybind/error.rb', line 16 def initialize(type, value, traceback) @type = type @value = value @traceback = traceback super("#{type}: #{value}") end |
Instance Attribute Details
#traceback ⇒ Object (readonly)
Returns the value of attribute traceback.
23 24 25 |
# File 'lib/pybind/error.rb', line 23 def traceback @traceback end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/pybind/error.rb', line 23 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
23 24 25 |
# File 'lib/pybind/error.rb', line 23 def value @value end |
Class Method Details
.fetch ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pybind/error.rb', line 3 def self.fetch ptrs = FFI::MemoryPointer.new(:pointer, 3) ptype = ptrs + 0 * ptrs.type_size pvalue = ptrs + 1 * ptrs.type_size ptraceback = ptrs + 2 * ptrs.type_size LibPython.PyErr_Fetch(ptype, pvalue, ptraceback) LibPython.PyErr_NormalizeException(ptype, pvalue, ptraceback) type = TypeCast.from_python(PyObjectStruct.new(ptype.read(:pointer))) value = TypeCast.from_python(PyObjectStruct.new(pvalue.read(:pointer))) traceback = TypeCast.from_python(PyObjectStruct.new(ptraceback.read(:pointer))) new(type, value, traceback) end |
Instance Method Details
#message ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/pybind/error.rb', line 25 def baseline = super lines = [baseline] + PyBind.parse_traceback(traceback) lines.join("\n") rescue baseline end |