rospy: #2362 ROSInterruptException is now a subclass of KeyboardInterrupt

This commit is contained in:
Ken Conley 2010-01-20 01:46:50 +00:00
parent 07a5e7b5fc
commit 961006e290
2 changed files with 15 additions and 3 deletions

View File

@ -52,10 +52,12 @@ class ROSInitException(ROSException):
"""
pass
class ROSInterruptException(ROSException):
class ROSInterruptException(ROSException, KeyboardInterrupt):
"""
Exception for operations that interrupted, e.g. due to shutdown
Exception for operations that interrupted, e.g. due to shutdown.
This is a subclass of both L{ROSException} and KeyboardInterrupt
so that it can be used in logic tht expects either.
"""
pass

View File

@ -55,7 +55,17 @@ class TestRospyExceptions(unittest.TestCase):
TransportException, TransportTerminated, TransportInitError]:
exc = e('foo')
self.assert_(isinstance(exc, ROSInternalException))
def test_ROSInterruptException(self):
from rospy.exceptions import ROSInterruptException, ROSException
try:
raise ROSInterruptException("test")
except ROSException:
pass
try:
raise ROSInterruptException("test")
except KeyboardInterrupt:
pass
if __name__ == '__main__':
import rostest