lib/pycall/pyerror.rb in pycall-0.1.0.alpha.20170224 vs lib/pycall/pyerror.rb in pycall-0.1.0.alpha.20170226
- old
+ new
@@ -15,11 +15,21 @@
def initialize(type, value, traceback)
@type = type
@value = value
@traceback = traceback
- super("#{@type.inspect}: #{PyCall.eval('str').(@value)}")
+ super("Error occurred in Python")
end
attr_reader :type, :value, :traceback
+
+ def message
+ "#{PyObject.new(type.to_ptr)}: #{value}".tap do |msg|
+ unless traceback.null?
+ if (o = PyCall.format_traceback(traceback))
+ msg.concat("\n", *o)
+ end
+ end
+ end
+ end
end
end