Go to the documentation of this file.00001
00002
00003
00004 '''rtctree
00005
00006 Copyright (C) 2009-2014
00007 Geoffrey Biggs
00008 RT-Synthesis Research Group
00009 Intelligent Systems Research Institute,
00010 National Institute of Advanced Industrial Science and Technology (AIST),
00011 Japan
00012 All rights reserved.
00013 Licensed under the Eclipse Public License -v 1.0 (EPL)
00014 http://www.opensource.org/licenses/eclipse-1.0.txt
00015
00016 General exception classes.
00017
00018 '''
00019
00020
00021 import rtctree
00022 import RTC
00023
00024
00025
00026
00027
00028 class RtcTreeError(Exception):
00029 '''Base error class.
00030
00031 Used for undefined errors that are not core Python errors.
00032
00033 '''
00034 pass
00035
00036
00037 class ReturnCodeError(RtcTreeError):
00038 '''Generic error using a value of ReturnCode_t to set the message.'''
00039 def __init__(self, return_code):
00040 '''Constructor.
00041
00042 @param return_code The type of return code. Must be on of the return
00043 codes defined in the RTC IDL.
00044
00045 '''
00046 if return_code == RTC.RTC_ERROR:
00047 RtcTreeError.__init__(self, 'General error')
00048 elif return_code == RTC.BAD_PARAMETER:
00049 RtcTreeError.__init__(self, 'Bad parameter')
00050 elif return_code == RTC.UNSUPPORTED:
00051 RtcTreeError.__init__(self, 'Unsupported')
00052 elif return_code == RTC.OUT_OF_RESOURCES:
00053 RtcTreeError.__init__(self, 'Out of resources')
00054 elif return_code == RTC.PRECONDITION_NOT_MET:
00055 RtcTreeError.__init__(self, 'Precondition not met')
00056
00057
00058 class InvalidServiceError(RtcTreeError):
00059 '''Could not connect to a CORBA service at an address.'''
00060 def __str__(self):
00061 return 'Invalid CORBA naming service: {0}'.format(self.args[0])
00062
00063
00064 class FailedToNarrowRootNamingError(RtcTreeError):
00065 '''Failed to narrow the root naming context of a name server.'''
00066 def __str__(self):
00067 return 'Failed to narrow root naming context {0}'.format(self.args[0])
00068
00069
00070 class NonRootPathError(RtcTreeError):
00071 '''A path did not begin with '/'.'''
00072 def __str__(self):
00073 return 'Path does not start at root: {0}'.format(self.args[0])
00074
00075
00076 class CannotHoldChildrenError(RtcTreeError):
00077 '''Tried to add a child to a node that cannot hold children.'''
00078 def __str__(self):
00079 return 'Node cannot hold children.'
00080
00081
00082 class BadECIndexError(RtcTreeError):
00083 '''Given the index of an execution context beyond the number of owned/
00084 participating contexts.
00085
00086 '''
00087 def __str__(self):
00088 return 'Bad execution context index: {0}'.format(self.args[0])
00089
00090
00091 class NoECWithHandleError(RtcTreeError):
00092 '''No execution context exists with the given handle.'''
00093 def __str__(self):
00094 return ('No execution context exists with ec_handle '
00095 '{0}'.format(self.args[0]))
00096
00097
00098 class WrongPortTypeError(RtcTreeError):
00099 '''Tried to connect two ports of incompatible type.'''
00100 def __str__(self):
00101 return 'Wrong port type.'
00102
00103
00104 class IncompatibleDataPortConnectionPropsError(RtcTreeError):
00105 '''Given incompatible properties for a connection between two data ports.'''
00106 def __str__(self):
00107 return 'Incompatible connection properties.'
00108
00109
00110 class FailedToConnectError(ReturnCodeError):
00111 '''Failed to make a connection between two ports.'''
00112 def __str__(self):
00113 return 'Failed to make connection: {0}'.format(self.args[0])
00114
00115
00116 class MismatchedInterfacesError(RtcTreeError):
00117 '''Interfaces between two service ports do not match type.'''
00118 def __str__(self):
00119 return 'Interfaces do not match.'
00120
00121
00122 class MismatchedPolarityError(RtcTreeError):
00123 '''Interfaces between two service ports do not match polarity.'''
00124 def __str__(self):
00125 return 'Polarities do not match.'
00126
00127
00128 class NotConnectedError(RtcTreeError):
00129 '''A connection is not connected.'''
00130 def __str__(self):
00131 return 'Not connected.'
00132
00133
00134 class UnknownConnectionOwnerError(RtcTreeError):
00135 '''A connection's owning port is not known.'''
00136 def __str__(self):
00137 return 'Connection owner unknown.'
00138
00139
00140 class NoSuchConfSetError(RtcTreeError):
00141 '''Attempted to access a configuration set that doesn't exist.'''
00142 def __str__(self):
00143 return 'No such configuration set: {0}'.format(self.args[0])
00144
00145
00146 class NoSuchConfParamError(RtcTreeError):
00147 '''Attempted to access a configuration parameter that doesn't exist.'''
00148 def __str__(self):
00149 return 'No such configuration parameter: {0}'.format(self.args[0])
00150
00151
00152 class NoSuchOptionError(RtcTreeError):
00153 '''The requested option has not been set.'''
00154 def __str__(self):
00155 return 'No such option: {0}'.format(self.args[0])
00156
00157
00158 class BadPathError(RtcTreeError):
00159 '''Error indicating an invalid path.'''
00160 def __str__(self):
00161 return 'Bad path: {0}'.format(self.args[0])
00162
00163
00164 class ManagerError(RtcTreeError):
00165 '''Base error type for errors involving managers.'''
00166 def __str__(self):
00167 return 'Unknown manager error'
00168
00169
00170 class FailedToLoadModuleError(ManagerError):
00171 '''Error loading a shared library into a manager.'''
00172 def __str__(self):
00173 if len(self.args) == 1:
00174 return 'Failed to load module: {0}'.format(self.args[0])
00175 else:
00176 return 'Failed to load module: {0}'.format(self.args)
00177
00178
00179 class FailedToUnloadModuleError(ManagerError):
00180 '''Error unloading a shared library from a manager.'''
00181 def __str__(self):
00182 return 'Failed to unload module: {0}'.format(self.args[0])
00183
00184
00185 class FailedToCreateComponentError(ManagerError):
00186 '''Error creating a component out of a shared library in a manager.'''
00187 def __str__(self):
00188 return 'Failed to create component: {0}'.format(self.args[0])
00189
00190
00191 class FailedToDeleteComponentError(ManagerError):
00192 '''Error deleting a component from a manager.'''
00193 def __str__(self):
00194 return 'Failed to delete component: {0}'.format(self.args[0])
00195
00196
00197 class FailedToSetConfigurationError(ManagerError):
00198 '''Error setting a manager configuration parameter.'''
00199 def __str__(self):
00200 return 'Failed to set configuration: {0}'.format(self.args[0])
00201
00202
00203 class FailedToAddMasterManagerError(ManagerError):
00204 '''Error when adding a master manager to another manager.'''
00205 def __str__(self):
00206 return 'Failed to add master manager.'
00207
00208
00209 class FailedToRemoveMasterManagerError(ManagerError):
00210 '''Error when removing a master manager.'''
00211 def __str__(self):
00212 return 'Failed to remove master manager.'
00213
00214
00215 class FailedToAddSlaveManagerError(ManagerError):
00216 '''Error when adding a slave manager to another manager.'''
00217 def __str__(self):
00218 return 'Failed to add slave manager: {0}'.format(self.args[1])
00219
00220
00221 class FailedToRemoveSlaveManagerError(ManagerError):
00222 '''Error when removing a slave manager.'''
00223 def __str__(self):
00224 return 'Failed to remove slave manager: {0}'.format(self.args[1])
00225
00226
00227 class NotRelatedError(RtcTreeError):
00228 '''Tried to manupulate the relationship between two nodes that are not
00229 parent and child.'''
00230 def __str__(self):
00231 return 'Nodes are not related: {0}, {1}'.format(self.args[0],
00232 self.args[1])
00233
00234
00235 class NoSuchEventError(RtcTreeError):
00236 '''Tried to register a callback for a non-existent event.'''
00237 def __str__(self):
00238 return 'Callback event {0} does not exist on node {1}.'.format(
00239 self.args[1], self.args[0])
00240
00241
00242 class AddLoggerError(RtcTreeError):
00243 '''Error adding a logger to a node.'''
00244 def __str__(self):
00245 return 'Error adding logger to node {0}.'.format(
00246 self.args[0])
00247
00248
00249 class NoCBError(RtcTreeError):
00250 '''Tried to remove an unregistered callback.'''
00251 def __str__(self):
00252 return 'Callback {0}:{1} does not exist on node {2}.'.format(
00253 self.args[1], self.args[2], self.args[0])
00254
00255
00256 class NoLoggerError(RtcTreeError):
00257 '''Tried to remove an unregistered logger.'''
00258 def __str__(self):
00259 return 'Logger {0} does not exist on node {1}.'.format(
00260 self.args[0], self.args[1])
00261
00262
00263 class NotCompositeError(RtcTreeError):
00264 '''The component is not a composite component.'''
00265 def __str__(self):
00266 return 'Component {0} is not a composite component.'.format(
00267 self.args[0])
00268
00269
00270 class NotInCompositionError(RtcTreeError):
00271 '''The component is not a member of the specified composite component.'''
00272 def __str__(self):
00273 return 'Component {0} is not a member of composition {1}.'.format(
00274 self.args[1], self.args[0])
00275
00276
00277 class AlreadyInCompositionError(RtcTreeError):
00278 '''The component is already a member of the composite component.'''
00279 def __str__(self):
00280 return 'Component {0} is already a member of composition {1}.'.format(
00281 self.args[1], self.args[0])
00282
00283
00284 class NotCORBANameError(RtcTreeError):
00285 '''A passed parameter is not a valid CORBA CosNaming.Name.'''
00286 def __str__(self):
00287 return 'Not a CORBA CosNaming.Name: {0}'.format(self.args[0])
00288
00289
00290
00291