From 720290a60afeffcf660269b3379488b5868b8d58 Mon Sep 17 00:00:00 2001
From: CaseyBatten <caseyhbatten@gmail.com>
Date: Wed, 18 Sep 2024 12:13:03 -0400
Subject: [PATCH] cleanup and location error case

---
 api/src/opentrons/protocol_api/robot_context.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/api/src/opentrons/protocol_api/robot_context.py b/api/src/opentrons/protocol_api/robot_context.py
index 5f4d34a9929f..b0bfaf546c6d 100644
--- a/api/src/opentrons/protocol_api/robot_context.py
+++ b/api/src/opentrons/protocol_api/robot_context.py
@@ -177,8 +177,7 @@ def axis_coordinates_for(
                 top_of_labware = loc.wells()[0].top()
                 loc = top_of_labware.point
                 return {mount_axis: loc.z, AxisType.X: loc.x, AxisType.Y: loc.y}
-            elif location is DeckLocation:
-                assert not isinstance(location, Location)
+            elif location is DeckLocation and not isinstance(location, Location):
                 slot_name = validation.ensure_and_convert_deck_slot(
                     location,
                     api_version=self._api_version,
@@ -186,10 +185,14 @@ def axis_coordinates_for(
                 )
                 loc = self._protocol_core.get_slot_center(slot_name)
                 return {mount_axis: loc.z, AxisType.X: loc.x, AxisType.Y: loc.y}
-            else:
+            elif isinstance(location, Location):
                 assert isinstance(location, Location)
                 loc = location.point
                 return {mount_axis: loc.z, AxisType.X: loc.x, AxisType.Y: loc.y}
+            else:
+                raise ValueError(
+                    "Location parameter must be a Module, Deck Location, or Location type."
+                )
         else:
             raise TypeError("You must specify a location to move to.")