Appendix C. Jython Exceptions
The following is a list of Python language exceptions raised by Jython, along with a discussion of their potential Java equivalents. Deprecated exceptions are not included.
ArithmeticError
Abstract base class of all the mathematical exceptions (such as
ZeroDivisionError
).AssertionError
Raised by Python’s
assert
statement, which has the formassert
expression
,
message
. If the expression evaluates to false, the exception is raised, with the optional message as additional data. In Java 1.4, an assert statement and anAssertionError
have been added to the language.AttributeError
Raised when an attempt to reference or call an object attribute fails because the object does not have the attribute. The attribute name is the value of the exception. Java generally catches these in compilation, but if you are using reflection, it can either be a
NoSuchFieldException
or aNoSuchMethodException
. If you try to call an attribute of aNone
value, you’ll get this exception as well, soNullPointerException
is also related.EnvironmentError
Abstract base class for exceptions raised outside Jython (such as
OSError
andIOError
). Usually created with two arguments. The first is placed in an attribute callederrno
, and the second is in the attributestrerror
and is usually the external error message. There is an optional third attribute,filename
.EOFError
Raised when a built-in read function hits the end of a file and hasn’t read any data. Similar to
java.io.EOFException
.Exception ...
Get Jython Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.