mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 08:37:42 +00:00
Fix: Handle ValueError when converting plane names
This commit is contained in:
parent
2e4ea37ca6
commit
80429efe72
@ -67,14 +67,14 @@ class MapPlane(Keyword):
|
|||||||
try:
|
try:
|
||||||
_ = self.floors[floor - 1]
|
_ = self.floors[floor - 1]
|
||||||
return floor
|
return floor
|
||||||
except IndexError:
|
except (IndexError, ValueError):
|
||||||
raise ScriptError(f'Plane {self} does not have floor index {floor}')
|
raise ScriptError(f'Plane {self} does not have floor index {floor}')
|
||||||
elif isinstance(floor, str):
|
elif isinstance(floor, str):
|
||||||
# Convert to floor index
|
# Convert to floor index
|
||||||
floor = floor.upper()
|
floor = floor.upper()
|
||||||
try:
|
try:
|
||||||
return self.floors.index(floor) + 1
|
return self.floors.index(floor) + 1
|
||||||
except IndexError:
|
except (IndexError, ValueError):
|
||||||
raise ScriptError(f'Plane {self} does not have floor name {floor}')
|
raise ScriptError(f'Plane {self} does not have floor name {floor}')
|
||||||
else:
|
else:
|
||||||
raise ScriptError(f'Plane {self} does not have floor {floor}')
|
raise ScriptError(f'Plane {self} does not have floor {floor}')
|
||||||
@ -95,7 +95,7 @@ class MapPlane(Keyword):
|
|||||||
# Convert to floor index
|
# Convert to floor index
|
||||||
try:
|
try:
|
||||||
return self.floors[floor - 1]
|
return self.floors[floor - 1]
|
||||||
except IndexError:
|
except (IndexError, ValueError):
|
||||||
raise ScriptError(f'Plane {self} does not have floor index {floor}')
|
raise ScriptError(f'Plane {self} does not have floor index {floor}')
|
||||||
elif isinstance(floor, str):
|
elif isinstance(floor, str):
|
||||||
# Check exist
|
# Check exist
|
||||||
@ -103,7 +103,7 @@ class MapPlane(Keyword):
|
|||||||
try:
|
try:
|
||||||
_ = self.floors.index(floor) + 1
|
_ = self.floors.index(floor) + 1
|
||||||
return floor
|
return floor
|
||||||
except IndexError:
|
except (IndexError, ValueError):
|
||||||
raise ScriptError(f'Plane {self} does not have floor name {floor}')
|
raise ScriptError(f'Plane {self} does not have floor name {floor}')
|
||||||
else:
|
else:
|
||||||
raise ScriptError(f'Plane {self} does not have floor {floor}')
|
raise ScriptError(f'Plane {self} does not have floor {floor}')
|
||||||
|
Loading…
Reference in New Issue
Block a user