Package rocon_hub_client :: Module exceptions
[frames] | no frames]

Source Code for Module rocon_hub_client.exceptions

 1  #!/usr/bin/env python 
 2  # 
 3  # License: BSD 
 4  #   https://raw.github.com/robotics-in-concert/rocon_multimaster/master/rocon_hub_client/LICENSE 
 5  # 
 6   
 7  ''' 
 8    Core exceptions raised when interacting with a rocon hub. 
 9  ''' 
10  ############################################################################## 
11  # Imports 
12  ############################################################################## 
13   
14  from gateway_msgs.msg import ErrorCodes 
15   
16  ############################################################################## 
17  # Exceptions 
18  ############################################################################## 
19   
20   
21 -class HubError(Exception):
22 - def __init__(self, msg):
23 super(HubError, self).__init__(msg) 24 self.id = ''
25 26 27 # Raised when the gateway can't connect to the hub's redis server
28 -class HubNotFoundError(HubError):
29 - def __init__(self, msg):
30 super(HubNotFoundError, self).__init__(msg) 31 self.id = ErrorCodes.HUB_CONNECTION_UNRESOLVABLE
32 33 34 # Raised when the hub's redis server has no key setting for the hub name.
35 -class HubNameNotFoundError(HubError):
36 - def __init__(self, msg):
37 super(HubNameNotFoundError, self).__init__(msg) 38 self.id = ErrorCodes.HUB_NAME_NOT_FOUND
39 40 41 # When the hub name or uri is in the blacklist
42 -class HubConnectionBlacklistedError(HubError):
43 - def __init__(self, msg):
44 super(HubConnectionBlacklistedError, self).__init__(msg) 45 self.id = ErrorCodes.HUB_CONNECTION_BLACKLISTED
46 47 48 # When the hub name or uri is not in a non-empty whitelist
49 -class HubConnectionNotWhitelistedError(HubError):
50 - def __init__(self, msg):
51 super(HubConnectionNotWhitelistedError, self).__init__(msg) 52 self.id = ErrorCodes.HUB_CONNECTION_NOT_IN_NONEMPTY_WHITELIST
53 54 55 # When the hub name or uri is not in a non-empty whitelist
56 -class HubConnectionAlreadyExistsError(HubError):
57 - def __init__(self, msg):
58 super(HubConnectionAlreadyExistsError, self).__init__(msg) 59 self.id = ErrorCodes.HUB_CONNECTION_NOT_IN_NONEMPTY_WHITELIST
60 61 62 # Raised when a hub client tries an operation on a hub that has lost its 63 # connection
64 -class HubConnectionLostError(HubError):
65 - def __init__(self, msg):
66 super(HubConnectionLostError, self).__init__(msg) 67 self.id = ErrorCodes.HUB_CONNECTION_NOT_IN_NONEMPTY_WHITELIST
68