Error Handling - ArrayIndexOutOfBoundsException

I have a situation where I need to handle an exception due to an ArrayIndexOutOfBoundsException. In the manual, it says that this can be called out for an exception-specific failover. However, another error is thrown saying that ‘ArrayIndexOutOfBoundsException’ is not defined.

Using the example code from the manual, this is the code I’m trying to use.

myDataset = system.dataset.toDataSet([“colName”], [[0]])
try:
print myDataset.getValueAt(0,5)
except ArrayIndexOutOfBoundsException:
print “Index Out of Bounds”

Any thoughts would be very helpful.

Thanks

I answered my own question. The key is to import java.lang.Exception and change the except to except java.lang.ArrayIndexOutOfBoundsException:.

Code now look like this and works:

import java.lang.Exception

myDataset = system.dataset.toDataSet([“colName”], [[0]])
try:
print myDataset.getValueAt(0,5)
except java.lang.ArrayIndexOutOfBoundsException:
print “Index Out of Bounds”

Would be nice if that page in the manual could be updated because some of the code examples are incorrect.

2 Likes