mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
write PythonUtil.describeException
This commit is contained in:
parent
d9d36d9a8e
commit
c0ace4ee5d
@ -238,6 +238,11 @@ class ConnectionRepository(DirectObject.DirectObject):
|
|||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
# Ensure the latest has been sent to the server.
|
||||||
|
if self.tcpConn:
|
||||||
|
self.tcpConn.flush()
|
||||||
|
|
||||||
def ensureValidConnection(self):
|
def ensureValidConnection(self):
|
||||||
# Was the connection reset?
|
# Was the connection reset?
|
||||||
if self.connectHttp:
|
if self.connectHttp:
|
||||||
|
@ -687,6 +687,34 @@ def findPythonModule(module):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def describeException(backTrace = 4):
|
||||||
|
# When called in an exception handler, returns a string describing
|
||||||
|
# the current exception.
|
||||||
|
|
||||||
|
infoArr = sys.exc_info()
|
||||||
|
exception = infoArr[0]
|
||||||
|
exceptionName = getattr(exception, '__name__', None)
|
||||||
|
extraInfo = infoArr[1]
|
||||||
|
trace = infoArr[2]
|
||||||
|
|
||||||
|
stack = []
|
||||||
|
while trace.tb_next:
|
||||||
|
module = trace.tb_frame.f_globals.get('__name__', None)
|
||||||
|
lineno = trace.tb_lineno
|
||||||
|
stack.append("%s:%s, " % (module, lineno))
|
||||||
|
trace = trace.tb_next
|
||||||
|
|
||||||
|
module = trace.tb_frame.f_globals.get('__name__', None)
|
||||||
|
lineno = trace.tb_lineno
|
||||||
|
stack.append("%s:%s, " % (module, lineno))
|
||||||
|
|
||||||
|
description = ""
|
||||||
|
for i in range(len(stack) - 1, max(len(stack) - backTrace, 0) - 1, -1):
|
||||||
|
description += stack[i]
|
||||||
|
|
||||||
|
description += "%s: %s" % (exceptionName, extraInfo)
|
||||||
|
return description
|
||||||
|
|
||||||
class PureVirtual:
|
class PureVirtual:
|
||||||
""" Python classes that want to have C++-style pure-virtual functions
|
""" Python classes that want to have C++-style pure-virtual functions
|
||||||
can derive from this class and call 'derivedMustOverride' from their
|
can derive from this class and call 'derivedMustOverride' from their
|
||||||
@ -698,3 +726,4 @@ class PureVirtual:
|
|||||||
and are not meant to be chained down to. This simulates C++
|
and are not meant to be chained down to. This simulates C++
|
||||||
pure-virtual methods. """
|
pure-virtual methods. """
|
||||||
raise 'error: derived class must implement %s' % callerInfo()[2]
|
raise 'error: derived class must implement %s' % callerInfo()[2]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user