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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPyException(PyObject type) PyException(PyObject type, String value) PyException(PyObject type, PyObject value) PyException(PyObject type, PyObject value, PyTraceback traceback) -
Method Summary
Modifier and TypeMethodDescriptionstatic PyExceptionLogic for the raise statementstatic StringGet the name of the exception's classstatic booleanisExceptionClass(PyObject obj) Determine whether obj is a Python exception classstatic booleanDetermine whether obj is an Python exception instancebooleanDetermine if this PyException is a match for exc.voidInstantiates the exception value if it is not already an instance.voidvoidbooleanOptional operation.voidtoString()voidtracebackHere(PyFrame here) Register frame as having been visited in the traceback.voidtracebackHere(PyFrame here, boolean isFinally) Register frame as having been visited in the traceback.intTraverses all directly containedPyObjects.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:
printStackTracein classThrowable
-
fillInStackTrace
- Overrides:
fillInStackTracein classThrowable
-
getMessage
- Overrides:
getMessagein classThrowable
-
printStackTrace
- Overrides:
printStackTracein 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:TraverseprocTraverses all directly containedPyObjects. Like in CPython,argmust be passed unmodified tovisitas 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 anullPyObject-argument.- Specified by:
traversein interfaceTraverseproc
-
refersDirectlyTo
Description copied from interface:TraverseprocOptional operation. Should only be implemented if it is more efficient than callingTraverseproc.traverse(Visitproc, Object)with a visitproc that just watches out forob. Must returnfalseifobisnull.- Specified by:
refersDirectlyToin interfaceTraverseproc
-