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.
ArithmeticErrorAbstract base class of all the mathematical exceptions (such as
ZeroDivisionError).AssertionErrorRaised by Python’s
assertstatement, which has the formassertexpression,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 anAssertionErrorhave been added to the language.AttributeErrorRaised 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
NoSuchFieldExceptionor aNoSuchMethodException. If you try to call an attribute of aNonevalue, you’ll get this exception as well, soNullPointerExceptionis also related.EnvironmentErrorAbstract base class for exceptions raised outside Jython (such as
OSErrorandIOError). Usually created with two arguments. The first is placed in an attribute callederrno, and the second is in the attributestrerrorand is usually the external error message. There is an optional third attribute,filename.EOFErrorRaised when a built-in read function hits the end of a file and hasn’t read any data. Similar to
java.io.EOFException.Exception ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access