Skip to content

Commit

Permalink
addressed TODO to more appropriately name exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoegenburg committed Oct 17, 2024
1 parent 6feaff0 commit 936b91c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
6 changes: 4 additions & 2 deletions api/src/opentrons/protocol_engine/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
CommandNotAllowedError,
InvalidLiquidHeightFound,
LiquidHeightUnknownError,
InvalidWellDefinitionError,
IncompleteLabwareDefinitionError,
IncompleteWellDefinitionError,
OperationLocationNotInWellError,
InvalidDispenseVolumeError,
)
Expand Down Expand Up @@ -153,7 +154,8 @@
"CommandNotAllowedError",
"InvalidLiquidHeightFound",
"LiquidHeightUnknownError",
"InvalidWellDefinitionError",
"IncompleteLabwareDefinitionError",
"IncompleteWellDefinitionError",
"OperationLocationNotInWellError",
"InvalidDispenseVolumeError",
]
19 changes: 16 additions & 3 deletions api/src/opentrons/protocol_engine/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,16 +1071,29 @@ def __init__(
super().__init__(ErrorCodes.GENERAL_ERROR, message, details, wrapping)


class InvalidWellDefinitionError(ProtocolEngineError):
"""Raised when an InnerWellGeometry definition is invalid."""
class IncompleteLabwareDefinitionError(ProtocolEngineError):
"""Raised when a labware definition lacks innerLabwareGeometry in general or for a specific well_id."""

def __init__(
self,
message: Optional[str] = None,
details: Optional[Dict[str, Any]] = None,
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build an InvalidWellDefinitionError."""
"""Build an IncompleteLabwareDefinitionError."""
super().__init__(ErrorCodes.GENERAL_ERROR, message, details, wrapping)


class IncompleteWellDefinitionError(ProtocolEngineError):
"""Raised when a well definition lacks a geometryDefinitionId."""

def __init__(
self,
message: Optional[str] = None,
details: Optional[Dict[str, Any]] = None,
wrapping: Optional[Sequence[EnumeratedError]] = None,
) -> None:
"""Build an IncompleteWellDefinitionError."""
super().__init__(ErrorCodes.GENERAL_ERROR, message, details, wrapping)


Expand Down
13 changes: 6 additions & 7 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,23 +500,22 @@ def get_well_geometry(
self, labware_id: str, well_name: Optional[str] = None
) -> InnerWellGeometry:
"""Get a well's inner geometry by labware and well name."""
# TODO(pbm, 10-11-24): wordsmith this error
labware_def = self.get_definition(labware_id)
if labware_def.innerLabwareGeometry is None:
raise errors.InvalidWellDefinitionError(
message=f"No innerLabwareGeometry found for labware_id: {labware_id}."
raise errors.IncompleteLabwareDefinitionError(
message=f"No innerLabwareGeometry found in labware definition for labware_id: {labware_id}."
)
well_def = self.get_well_definition(labware_id, well_name)
well_id = well_def.geometryDefinitionId
if well_id is None:
raise errors.InvalidWellDefinitionError(
message=f"No geometryDefinitionId found for well: {well_name} in labware_id: {labware_id}"
raise errors.IncompleteWellDefinitionError(
message=f"No geometryDefinitionId found in well definition for well: {well_name} in labware_id: {labware_id}"
)
else:
well_geometry = labware_def.innerLabwareGeometry.get(well_id)
if well_geometry is None:
raise errors.InvalidWellDefinitionError(
message=f"No innerLabwareGeometry found for well_id: {well_id} in labware_id: {labware_id}"
raise errors.IncompleteLabwareDefinitionError(
message=f"No innerLabwareGeometry found in labware definition for well_id: {well_id} in labware_id: {labware_id}"
)
return well_geometry

Expand Down

0 comments on commit 936b91c

Please sign in to comment.