From bf93b02cdc82086b32e2bd16f4b506c1bb76c65d Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:17:28 +0200 Subject: [PATCH] fix: error message if motor do not have limits attribute --- .../examples/motor_movement/motor_example.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bec_widgets/examples/motor_movement/motor_example.py b/bec_widgets/examples/motor_movement/motor_example.py index 79372248..8cc06061 100644 --- a/bec_widgets/examples/motor_movement/motor_example.py +++ b/bec_widgets/examples/motor_movement/motor_example.py @@ -563,7 +563,21 @@ class MotorControl(QThread): return self.current_x, self.current_y def get_motor_limits(self, motor) -> list: - return motor.limits + """ + Retrieve the limits for a specific motor. + + Args: + motor (object): Motor object. + + Returns: + tuple: Lower and upper limit for the motor. + """ + try: + return motor.limits + except AttributeError: + # If the motor doesn't have a 'limits' attribute, return a default value or raise a custom exception + print(f"The device {motor} does not have defined limits.") + return None def retrieve_motor_limits(self, motor_x, motor_y): limit_x = self.get_motor_limits(motor_x)