Skip to content

Commit

Permalink
Use super to set error reason for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aeshub committed Jun 8, 2023
1 parent 9f21717 commit 282a070
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/robot_interface/models/exceptions/robot_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,70 +38,136 @@ def __init__(self, error_reason: ErrorReason, error_description: str):
# An exception which should be thrown by the robot package if it is unable to
# communicate with the robot API.
class RobotCommunicationException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotCommunicationException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to start the
# current step.
class RobotInfeasibleStepException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotInfeasibleStepException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to start the
# current mission.
class RobotInfeasibleMissionException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotInfeasibleMissionException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to collect
# the status of the current mission.
class RobotMissionStatusException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotMissionStatusException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to collect
# the status of the current step.
class RobotStepStatusException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotStepStatusException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is able to communicate
# with the robot API but the result of the communication leads to an exception. An
# example could be a KeyError while reading from the response dictionary.
class RobotAPIException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotAPIException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to perform a
# requested action. For example the package is unable to stop the robot.
class RobotActionException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotActionException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if something is wrong during
# the initialization of the robot. This exception will cause the mission to fail as
# initialization is performed prior to starting the mission.
class RobotInitializeException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotInitializeException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to retrieve
# data from the API like currently executing missions, status of the current mission
# and similar.
class RobotRetrieveDataException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotRetrieveDataException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to collect
# the inspections that were generated for the currently executing step or mission.
class RobotRetrieveInspectionException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotRetrieveInspectionException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to retrieve
# telemetry data. It should be used exclusively by the telemetry publishers and their
# functions.
class RobotTelemetryException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotTelemetryException,
error_description=error_description,
)

pass


Expand All @@ -110,16 +176,34 @@ class RobotTelemetryException(RobotException):
# configuration and this exception will cause ISAR to crash as further execution is not
# advised.
class RobotMapException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotMapException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if it is unable to transform
# the coordinates correctly between asset and robot frame.
class RobotTransformException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotTransformException,
error_description=error_description,
)

pass


# An exception which should be thrown by the robot package if something occurred that
# was unexpected and the error reason is unknown.
class RobotUnknownErrorException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotUnknownErrorException,
error_description=error_description,
)

pass

0 comments on commit 282a070

Please sign in to comment.