rts_exceptions.py
Go to the documentation of this file.
00001 # -*- Python -*-
00002 # -*- coding: utf-8 -*-
00003 
00004 '''rtshell
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 Exceptions that may occur.
00017 
00018 '''
00019 
00020 
00021 import rtctree.path
00022 
00023 
00024 class RtShellError(Exception):
00025     '''Base error for all errors that may occur.'''
00026     pass
00027 
00028 
00029 class CallFailedError(Exception):
00030     '''An interface call failed.'''
00031     def __init__(self, msg):
00032         self._msg = msg
00033 
00034     def __str__(self):
00035         return 'Interface call failed: {0}'.format(self._msg)
00036 
00037 
00038 class RequiredActionFailedError(RtShellError):
00039     '''Error raised when an action that must succeed fails.'''
00040     def __init__(self, msg):
00041         self._msg = msg
00042 
00043     def __str__(self):
00044         return 'Required action failed: {0}'.format(self._msg)
00045 
00046 
00047 class PrecedingTimeoutError(RtShellError):
00048     '''The time limit on a preceding condition being met has elapsed.'''
00049     def __init__(self, msg):
00050         self._msg = msg
00051 
00052     def __str__(self):
00053         return 'Preceding condition timed out: {0}'.format(self._msg)
00054 
00055 
00056 class PlanExecutionError(RtShellError):
00057     '''An error occurred executing a plan.'''
00058     def __init__(self, error):
00059         self._error = error
00060 
00061     def __str__(self):
00062         return 'Error executing plan:\n{0}'.format(self._error)
00063 
00064 
00065 class EmptyConstExprError(RtShellError):
00066     '''A constant expression that should be evaluated is empty.'''
00067     def __str__(self):
00068         return 'Empty constant expression '
00069 
00070 
00071 class AmbiguousTypeError(RtShellError):
00072     '''A data type is ambiguous.'''
00073     def __init__(self, type):
00074         self._type = type
00075 
00076     def __str__(self):
00077         return 'Ambiguous port type: {0}'.format(self._type)
00078 
00079 
00080 class TypeNotFoundError(RtShellError):
00081     '''A data type was not found.'''
00082     def __init__(self, type):
00083         self._type = type
00084 
00085     def __str__(self):
00086         return 'Type not found: {0}'.format(self._type)
00087 
00088 
00089 class BadPortSpecError(RtShellError):
00090     '''A port specification is badly formatted.'''
00091     def __init__(self, ps):
00092         self._ps = ps
00093 
00094     def __str__(self):
00095         return 'Bad port specification: {0}'.format(self._ps)
00096 
00097 
00098 class SameNameDiffSpecError(RtShellError):
00099     '''A port spec has a different property from another with the same name.'''
00100     def __init__(self, ps):
00101         self._ps = ps
00102 
00103     def __str__(self):
00104         return 'Port specification with same name has different properties: '\
00105                 '{0}'.format(self._ps)
00106 
00107 
00108 class NoSuchObjectError(RtShellError):
00109     '''The given path does not point to the necessary object.'''
00110     def __init__(self, path):
00111         self._path = path
00112 
00113     def __str__(self):
00114         if type(self._path) == tuple:
00115             return 'No such object: {0}'.format(
00116                     rtctree.path.format_path(self._path))
00117         elif type(self._path) == list:
00118             return 'No such object: {0}'.format(
00119                     rtctree.path.format_path((self._path, None)))
00120         else:
00121             return 'No such object: {0}'.format(self._path)
00122 
00123 
00124 class NotAComponentOrManagerError(RtShellError):
00125     '''A given path is not a component nor a manager.'''
00126     def __init__(self, path):
00127         self._path = path
00128 
00129     def __str__(self):
00130         if type(self._path) == tuple:
00131             return 'Not a component or manager: {0}'.format(
00132                     rtctree.path.format_path(self._path))
00133         elif type(self._path) == list:
00134             return 'Not a component or manager: {0}'.format(
00135                     rtctree.path.format_path((self._path, None)))
00136         else:
00137             return 'Not a component or manager: {0}'.format(self._path)
00138 
00139 
00140 class NotAComponentError(RtShellError):
00141     '''A given path is not a component.'''
00142     def __init__(self, path):
00143         self._path = path
00144 
00145     def __str__(self):
00146         if type(self._path) == tuple:
00147             return 'Not a component: {0}'.format(
00148                     rtctree.path.format_path(self._path))
00149         elif type(self._path) == list:
00150             return 'Not a component: {0}'.format(
00151                     rtctree.path.format_path((self._path, None)))
00152         else:
00153             return 'Not a component: {0}'.format(self._path)
00154 
00155 
00156 class NotACompositeComponentError(RtShellError):
00157     '''A given path is not a composite component.'''
00158     def __init__(self, path):
00159         self._path = path
00160 
00161     def __str__(self):
00162         if type(self._path) == tuple:
00163             return 'Not a composite component: {0}'.format(
00164                     rtctree.path.format_path(self._path))
00165         elif type(self._path) == list:
00166             return 'Not a composite component: {0}'.format(
00167                     rtctree.path.format_path((self._path, None)))
00168         else:
00169             return 'Not a composite component: {0}'.format(self._path)
00170 
00171 
00172 class NotAPortError(RtShellError):
00173     '''A given path is not a port.'''
00174     def __init__(self, path):
00175         self._path = path
00176 
00177     def __str__(self):
00178         if type(self._path) == tuple:
00179             return 'Not a port: {0}'.format(
00180                     rtctree.path.format_path(self._path))
00181         elif type(self._path) == list:
00182             return 'Not a port: {0}'.format(
00183                     rtctree.path.format_path((self._path, None)))
00184         else:
00185             return 'Not a port: {0}'.format(self._path)
00186 
00187 
00188 class ParentNotADirectoryError(RtShellError):
00189     '''A given path's parent is not a directory.'''
00190     def __init__(self, path):
00191         self._path = path
00192 
00193     def __str__(self):
00194         if type(self._path) == tuple:
00195             return 'Parent not a directory: {0}'.format(
00196                     rtctree.path.format_path(self._path))
00197         elif type(self._path) == list:
00198             return 'Parent not a directory: {0}'.format(
00199                     rtctree.path.format_path((self._path, None)))
00200         else:
00201             return 'Parent not a directory: {0}'.format(self._path)
00202 
00203 
00204 class NotADirectoryError(RtShellError):
00205     '''A given path is not a directory.'''
00206     def __init__(self, path):
00207         self._path = path
00208 
00209     def __str__(self):
00210         if type(self._path) == tuple:
00211             return 'Not a directory: {0}'.format(
00212                     rtctree.path.format_path(self._path))
00213         elif type(self._path) == list:
00214             return 'Not a directory: {0}'.format(
00215                     rtctree.path.format_path((self._path, None)))
00216         else:
00217             return 'Not a directory: {0}'.format(self._path)
00218 
00219 
00220 class NotAPortError(RtShellError):
00221     '''A given path is not a port.'''
00222     def __init__(self, path):
00223         self._path = path
00224 
00225     def __str__(self):
00226         if type(self._path) == tuple:
00227             return 'Not a port: {0}'.format(
00228                     rtctree.path.format_path(self._path))
00229         elif type(self._path) == list:
00230             return 'Not a port: {0}'.format(
00231                     rtctree.path.format_path((self._path, None)))
00232         else:
00233             return 'Not a port: {0}'.format(self._path)
00234 
00235 
00236 class NotAManagerError(RtShellError):
00237     '''A given path is not a manager.'''
00238     def __init__(self, path):
00239         self._path = path
00240 
00241     def __str__(self):
00242         if type(self._path) == tuple:
00243             return 'Not a manager: {0}'.format(
00244                     rtctree.path.format_path(self._path))
00245         elif type(self._path) == list:
00246             return 'Not a manager: {0}'.format(
00247                     rtctree.path.format_path((self._path, None)))
00248         else:
00249             return 'Not a manager: {0}'.format(self._path)
00250 
00251 
00252 class NotInManagerError(RtShellError):
00253     '''A component name does not exist in a manager.'''
00254     def __init__(self, name):
00255         self._name = name
00256 
00257     def __str__(self):
00258         return '{0} is not in the manager.'.format(self._name)
00259 
00260 
00261 class UndeletableObjectError(RtShellError):
00262     '''Some objects cannot be deleted.'''
00263     def __init__(self, path):
00264         self._path = path
00265 
00266     def __str__(self):
00267         if type(self._path) == tuple:
00268             return 'Undeletable object: {0}'.format(
00269                     rtctree.path.format_path(self._path))
00270         elif type(self._path) == list:
00271             return 'Undeletable object: {0}'.format(
00272                     rtctree.path.format_path((self._path, None)))
00273         else:
00274             return 'Undeletable object: {0}'.format(self._path)
00275 
00276 
00277 class NotZombieObjectError(RtShellError):
00278     '''A given path does not point to a zombie.'''
00279     def __init__(self, path):
00280         self._path = path
00281 
00282     def __str__(self):
00283         if type(self._path) == tuple:
00284             return 'Not a zombie object: {0}'.format(
00285                     rtctree.path.format_path(self._path))
00286         elif type(self._path) == list:
00287             return 'Not a zombie object: {0}'.format(
00288                     rtctree.path.format_path((self._path, None)))
00289         else:
00290             return 'Not a zombie object: {0}'.format(self._path)
00291 
00292 
00293 class ZombieObjectError(RtShellError):
00294     '''A given path points to a zombie.'''
00295     def __init__(self, path):
00296         self._path = path
00297 
00298     def __str__(self):
00299         if type(self._path) == tuple:
00300             return 'Zombie object: {0}'.format(
00301                     rtctree.path.format_path(self._path))
00302         elif type(self._path) == list:
00303             return 'Zombie object: {0}'.format(
00304                     rtctree.path.format_path((self._path, None)))
00305         else:
00306             return 'Zombie object: {0}'.format(self._path)
00307 
00308 
00309 class UnknownObjectError(RtShellError):
00310     '''A given path points to an unknown object.'''
00311     def __init__(self, path):
00312         self._path = path
00313 
00314     def __str__(self):
00315         if type(self._path) == tuple:
00316             return 'Unknown object: {0}'.format(
00317                     rtctree.path.format_path(self._path))
00318         elif type(self._path) == list:
00319             return 'Unknown object: {0}'.format(
00320                     rtctree.path.format_path((self._path, None)))
00321         else:
00322             return 'Unknown object: {0}'.format(self._path)
00323 
00324 
00325 class NoDestPortError(RtShellError):
00326     '''A required destination port was not specified.'''
00327     def __str__(self):
00328         return 'No destination port specified.'
00329 
00330 
00331 class NoSourcePortError(RtShellError):
00332     '''A required source port was not specified.'''
00333     def __str__(self):
00334         return 'No source port specified.'
00335 
00336 
00337 class CannotDoToPortError(RtShellError):
00338     '''The action cannot be performed on a port.'''
00339     def __init__(self, action):
00340         self._action = action
00341 
00342     def __str__(self):
00343         return 'Cannot {0} ports.'.format(self._action)
00344 
00345 
00346 class PortNotFoundError(RtShellError):
00347     '''The port was not found on the component.'''
00348     def __init__(self, rtc, port):
00349         self._rtc = rtc
00350         self._port = port
00351 
00352     def __str__(self):
00353         return 'Port not found: {0}'.format(
00354                 rtctree.path.format_path((self._rtc, self._port)))
00355 
00356 
00357 class ConnectionNotFoundError(RtShellError):
00358     '''A connection between two ports was not found.'''
00359     def __init__(self, path1, path2):
00360         self._path1 = path1
00361         self._path2 = path2
00362 
00363     def __str__(self):
00364         if type(self._path1) == tuple:
00365             path1_str = rtctree.path.format_path(self._path1)
00366         elif type(self._path1) == list:
00367             path1_str = rtctree.path.format_path((self._path1, None))
00368         else:
00369             path1_str = self._path1
00370         if type(self._path2) == tuple:
00371             path2_str = rtctree.path.format_path(self._path2)
00372         elif type(self._path2) == list:
00373             path2_str = rtctree.path.format_path((self._path2, None))
00374         else:
00375             path2_str = self._path2
00376         return 'No connection from {0} to {1}'.format(path1_str, path2_str)
00377 
00378 
00379 class MultiConnectionNotFoundError(RtShellError):
00380     '''A connection between ports was not found.'''
00381     def __str__(self):
00382         return 'No connection found involving the specified ports.'''
00383 
00384 
00385 class ConnectionIDNotFoundError(RtShellError):
00386     '''The port was not found on the component.'''
00387     def __init__(self, id, path):
00388         self._id = id
00389         self._path = path
00390 
00391     def __str__(self):
00392         if type(self._path) == tuple:
00393             return 'No connection from {0} with ID {1}.'.format(
00394                     rtctree.path.format_path(self._path), self._id)
00395         elif type(self._path) == list:
00396             return 'No connection from {0} with ID {1}.'.format(
00397                     rtctree.path.format_path((self._path, None)), self._id)
00398         else:
00399             return 'No connection from {0} with ID {1}'.format(self._path,
00400                     self._id)
00401 
00402 
00403 class BadPortTypeError(RtShellError):
00404     '''The port type is not defined.'''
00405     def __init__(self, rtc, port):
00406         self._rtc = rtc
00407         self._port = port
00408 
00409     def __str__(self):
00410         return 'Incorrect port type: {0}'.format(
00411                 rtctree.path.format_path((self._rtc, self._port)))
00412 
00413 
00414 class MissingCompError(RtShellError):
00415     '''An expected component is missing.'''
00416     def __init__(self, path):
00417         self._path = path
00418 
00419     def __str__(self):
00420         return 'Expected component missing: {0}'.format(self._path)
00421 
00422 
00423 class ConnectFailedError(RtShellError):
00424     '''An error occured connecting two ports.'''
00425     def __init__(self, rtc, port):
00426         self._rtc = rtc
00427         self._port = port
00428 
00429     def __str__(self):
00430         return 'Failed to connect port: {0}'.format(
00431                 rtctree.path.format_path((self._rtc, self._port)))
00432 
00433 
00434 class ActivateError(RtShellError):
00435     '''An error occured activating a component.'''
00436     def __init__(self, comp):
00437         self._comp = comp
00438 
00439     def __str__(self):
00440         return 'Error activating component: {0}'.format(self._comp)
00441 
00442 
00443 class DeactivateError(RtShellError):
00444     '''An error occured deactivating a component.'''
00445     def __init__(self, comp):
00446         self._comp = comp
00447 
00448     def __str__(self):
00449         return 'Error deactivating component: {0}'.format(self._comp)
00450 
00451 
00452 class PortNotInputError(RtShellError):
00453     '''A port is not an input that should be.'''
00454     def __init__(self, name):
00455         self._name = name
00456 
00457     def __str__(self):
00458         return 'Port is not input: {0}'.format(self._name)
00459 
00460 
00461 class PortNotOutputError(RtShellError):
00462     '''A port is not an output that should be.'''
00463     def __init__(self, name):
00464         self._name = name
00465 
00466     def __str__(self):
00467         return 'Port is not output: {0}'.format(self._name)
00468 
00469 
00470 class ImportFormatterError(RtShellError):
00471     '''An error occured importing a formatting function.'''
00472     def __init__(self, exc):
00473         self._exc = exc
00474 
00475     def __str__(self):
00476         return 'Error importing formatter: {0}'.format(self._exc)
00477 
00478 
00479 class BadFormatterError(RtShellError):
00480     '''The imported formatter is bad (most likely not a function).'''
00481     def __init__(self, fun):
00482         self._fun = fun
00483 
00484     def __str__(self):
00485         return 'Bad formatter: {0}'.format(self._fun)
00486 
00487 
00488 class MissingPOAError(RtShellError):
00489     '''A data type from a module was used without a matching POA loaded.'''
00490     def __init__(self, mod):
00491         self._mod = mod
00492 
00493     def __str__(self):
00494         return 'Missing POA module: {0}'.format(self._mod)
00495 
00496 
00497 class NoConfSetError(RtShellError):
00498     '''The specified configuration set does not exist.'''
00499     def __init__(self, name):
00500         self._name = name
00501 
00502     def __str__(self):
00503         return 'No such configuration set: {0}'.format(self._name)
00504 
00505 
00506 class BadStartPointError(RtShellError):
00507     '''A given start point for the log is outside the bounds.'''
00508     def __str__(self):
00509         return 'Start time/index out of bounds.'
00510 
00511 
00512 class BadEndPointError(RtShellError):
00513     '''A given end point for the log is outside the bounds.'''
00514     def __str__(self):
00515         return 'End time/index out of bounds.'
00516 
00517 
00518 class BadLogTypeError(RtShellError):
00519     '''An invalid logger type was chosen.'''
00520     def __init__(self, type):
00521         self._type = type
00522 
00523     def __str__(self):
00524         return 'Invalid logger type: {0}'.format(self._type)
00525 
00526 
00527 class UnsupportedLogTypeError(RtShellError):
00528     '''The selected log type doesn't support the desired feature.'''
00529     def __init__(self, type, feature):
00530         self._type = type
00531         self._feature = feature
00532 
00533     def __str__(self):
00534         return 'Log type "{0}" does not support feature {1}.'.format(
00535                 self._type, self._feature)
00536 
00537 
00538 class NoLogFileNameError(RtShellError):
00539     '''An expected file name was not provided.'''
00540     def __str__(self):
00541         return 'No log file specified.'
00542 
00543 
00544 class BadMgrAddressError(RtShellError):
00545     '''A bad corbaloc address was given.'''
00546     def __str__(self):
00547         return 'Invalid corbaloc URL.'
00548 
00549 
00550 class FailedToNarrowError(RtShellError):
00551     '''Failed to narrow a CORBA object reference.'''
00552     def __str__(self):
00553         return 'Failed to narrow CORBA object reference.'
00554 
00555 
00556 class CannotRemoveFromNewCompositionError(RtShellError):
00557     '''Cannot remove components/ports from a new composition.'''
00558     def __str__(self):
00559         return 'Cannot remove components/ports from a new composition.'
00560 
00561 
00562 # vim: tw=79
00563 


rtshell
Author(s): Geoffrey Biggs
autogenerated on Fri Aug 28 2015 12:55:12