From 80429efe7277e3729147cd5c9223459c323bcc2e Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:13:01 +0800 Subject: [PATCH] Fix: Handle ValueError when converting plane names --- tasks/map/keywords/classes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/map/keywords/classes.py b/tasks/map/keywords/classes.py index 62ea35060..c2293e268 100644 --- a/tasks/map/keywords/classes.py +++ b/tasks/map/keywords/classes.py @@ -67,14 +67,14 @@ class MapPlane(Keyword): try: _ = self.floors[floor - 1] return floor - except IndexError: + except (IndexError, ValueError): raise ScriptError(f'Plane {self} does not have floor index {floor}') elif isinstance(floor, str): # Convert to floor index floor = floor.upper() try: return self.floors.index(floor) + 1 - except IndexError: + except (IndexError, ValueError): raise ScriptError(f'Plane {self} does not have floor name {floor}') else: raise ScriptError(f'Plane {self} does not have floor {floor}') @@ -95,7 +95,7 @@ class MapPlane(Keyword): # Convert to floor index try: return self.floors[floor - 1] - except IndexError: + except (IndexError, ValueError): raise ScriptError(f'Plane {self} does not have floor index {floor}') elif isinstance(floor, str): # Check exist @@ -103,7 +103,7 @@ class MapPlane(Keyword): try: _ = self.floors.index(floor) + 1 return floor - except IndexError: + except (IndexError, ValueError): raise ScriptError(f'Plane {self} does not have floor name {floor}') else: raise ScriptError(f'Plane {self} does not have floor {floor}')