Next: , Previous: Robj type, Up: Interface description


3.3 R exceptions

RPy implements a new exception type, called RException, which is derived from the base class of all exceptions Exception. This exception is raised when an error in the R interpreter occurred. The error message included in the exception is the message given by the R interpreter. For example:

     >>> RException
     <class rpy.RException at 0x8a72b44>
     >>>
     >>> r.t_test(1)
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     rpy.RException: Error in t.test.default(1) : not enough x observations

Note that not all operations with Robj objects raise this exception. When using the sequence protocol on Robj objects, the exceptions raised are IndexError, in order to properly use the for loop (see Sequence protocol). Other functions, such as mode functions, raise ValueError (see Modes).