You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exceptions.py 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (c) 2016 Anki, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the file LICENSE.txt or at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. '''SDK-specific exception classes.'''
  15. # __all__ should order by constants, event classes, other classes, functions.
  16. __all__ = ['CozmoSDKException', 'SDKShutdown', 'StopPropogation',
  17. 'AnimationsNotLoaded', 'ActionError', 'ConnectionError',
  18. 'ConnectionAborted', 'ConnectionCheckFailed', 'NoDevicesFound',
  19. 'SDKVersionMismatch', 'NotPickupable', 'CannotPlaceObjectsOnThis',
  20. 'RobotBusy', 'InvalidOpenGLGlutImplementation']
  21. class CozmoSDKException(Exception):
  22. '''Base class of all Cozmo SDK exceptions.'''
  23. class SDKShutdown(CozmoSDKException):
  24. '''Raised when the SDK is being shut down'''
  25. class StopPropogation(CozmoSDKException):
  26. '''Raised by event handlers to prevent further handlers from being triggered.'''
  27. class AnimationsNotLoaded(CozmoSDKException):
  28. '''Raised if an attempt is made to play a named animation before animations have been received.'''
  29. class ActionError(CozmoSDKException):
  30. '''Base class for errors that occur with robot actions.'''
  31. class ConnectionError(CozmoSDKException):
  32. '''Base class for errors regarding connection to the device.'''
  33. class ConnectionAborted(ConnectionError):
  34. '''Raised if the connection to the device is unexpectedly lost.'''
  35. class ConnectionCheckFailed(ConnectionError):
  36. '''Raised if the connection check has failed.'''
  37. class NoDevicesFound(ConnectionError):
  38. '''Raised if no devices connected running Cozmo in SDK mode'''
  39. class SDKVersionMismatch(ConnectionError):
  40. '''Raised if the Cozmo SDK version is not compatible with the software running on the device.'''
  41. def __init__(self, message, sdk_version, sdk_app_version, app_version, *args):
  42. super().__init__(message, sdk_version, sdk_app_version, app_version, *args)
  43. #: str: The SDK version number in Major.Minor.Patch format.
  44. #: See :ref:`sdk-versions` for which App version is compatible with each SDK version.
  45. self.sdk_version = sdk_version
  46. #: str: The version of the App that this SDK is compatible with in Major.Minor.Patch format.
  47. self.sdk_app_version = sdk_app_version
  48. #: str: The version of the App that was detected, and is incompatible, in Major.Minor.Patch format.
  49. self.app_version = app_version
  50. class NotPickupable(ActionError):
  51. '''Raised if an attempt is made to pick up or place an object that can't be picked up by Cozmo'''
  52. class CannotPlaceObjectsOnThis(ActionError):
  53. '''Raised if an attempt is made to place an object on top of an invalid object'''
  54. class RobotBusy(ActionError):
  55. '''Raised if an attempt is made to perform an action while another action is still running.'''
  56. class InvalidOpenGLGlutImplementation(ImportError):
  57. '''Raised by opengl viewer if no valid GLUT implementation available.'''