Package org.python.core
Class PyException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.python.core.PyException
- All Implemented Interfaces:
Serializable
,Traverseproc
- Direct Known Subclasses:
PyIndentationError
,PySyntaxError
A wrapper for all python exception. Note that the well-known python exceptions are not
subclasses of PyException. Instead the python exception class is stored in the
type
field and value or class instance is stored in the value
field.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPyException
(PyObject type) PyException
(PyObject type, String value) PyException
(PyObject type, PyObject value) PyException
(PyObject type, PyObject value, PyTraceback traceback) -
Method Summary
Modifier and TypeMethodDescriptionstatic PyException
Logic for the raise statementstatic String
Get the name of the exception's classstatic boolean
isExceptionClass
(PyObject obj) Determine whether obj is a Python exception classstatic boolean
Determine whether obj is an Python exception instanceboolean
Determine if this PyException is a match for exc.void
Instantiates the exception value if it is not already an instance.void
void
boolean
Optional operation.void
toString()
void
tracebackHere
(PyFrame here) Register frame as having been visited in the traceback.void
tracebackHere
(PyFrame here, boolean isFinally) Register frame as having been visited in the traceback.int
Traverses all directly containedPyObject
s.Methods inherited from class java.lang.Throwable
addSuppressed, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
-
Field Details
-
type
The python exception class (for class exception) or identifier (for string exception). -
value
The exception instance (for class exception) or exception value (for string exception). -
traceback
The exception traceback object.
-
-
Constructor Details
-
PyException
public PyException() -
PyException
-
PyException
-
PyException
-
PyException
-
-
Method Details
-
printStackTrace
public void printStackTrace()- Overrides:
printStackTrace
in classThrowable
-
fillInStackTrace
- Overrides:
fillInStackTrace
in classThrowable
-
getMessage
- Overrides:
getMessage
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
super__printStackTrace
-
toString
-
normalize
public void normalize()Instantiates the exception value if it is not already an instance. -
tracebackHere
Register frame as having been visited in the traceback.- Parameters:
here
- the current PyFrame
-
tracebackHere
Register frame as having been visited in the traceback.- Parameters:
here
- the current PyFrameisFinally
- whether caller is a Python finally block
-
doRaise
Logic for the raise statement- Parameters:
type
- the first arg to raise, a type or an instancevalue
- the second arg, the instance of the class or arguments to its constructortraceback
- a traceback object- Returns:
- a PyException wrapper
-
match
Determine if this PyException is a match for exc.- Parameters:
exc
- a PyObject exception type- Returns:
- true if a match
-
isExceptionClass
Determine whether obj is a Python exception class- Parameters:
obj
- a PyObject- Returns:
- true if an exception
-
isExceptionInstance
Determine whether obj is an Python exception instance- Parameters:
obj
- a PyObject- Returns:
- true if an exception instance
-
exceptionClassName
Get the name of the exception's class- Parameters:
obj
- a PyObject exception- Returns:
- String exception name
-
traverse
Description copied from interface:Traverseproc
Traverses all directly containedPyObject
s. Like in CPython,arg
must be passed unmodified tovisit
as its second parameter. IfVisitproc.visit(PyObject, Object)
returns nonzero, this return value must be returned immediately by traverse.Visitproc.visit(PyObject, Object)
must not be called with anull
PyObject-argument.- Specified by:
traverse
in interfaceTraverseproc
-
refersDirectlyTo
Description copied from interface:Traverseproc
Optional operation. Should only be implemented if it is more efficient than callingTraverseproc.traverse(Visitproc, Object)
with a visitproc that just watches out forob
. Must returnfalse
ifob
isnull
.- Specified by:
refersDirectlyTo
in interfaceTraverseproc
-