File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
api/src/opentrons/protocols/api_support
shared-data/python/opentrons_shared_data/errors Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 22
22
from opentrons .hardware_control .types import Axis
23
23
from opentrons .hardware_control .util import ot2_axis_to_string
24
24
from opentrons_shared_data .robot .dev_types import RobotType
25
+ from opentrons_shared_data .errors .exceptions import (
26
+ APIRemoved ,
27
+ IncorrectAPIVersion ,
28
+ )
25
29
26
30
if TYPE_CHECKING :
27
31
from opentrons .protocol_api .labware import Well , Labware
37
41
MODULE_LOG = logging .getLogger (__name__ )
38
42
39
43
40
- class APIVersionError (Exception ):
44
+ class APIVersionError (IncorrectAPIVersion ):
41
45
"""
42
46
Error raised when a protocol attempts to access behavior not implemented
43
47
"""
44
48
45
49
pass
46
50
47
51
48
- class UnsupportedAPIError (Exception ):
52
+ class UnsupportedAPIError (APIRemoved ):
49
53
"""Error raised when a protocol attempts to use unsupported API."""
50
54
51
55
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ class ErrorCodes(Enum):
92
92
INVALID_STORED_DATA = _code_from_dict_entry ("4008" )
93
93
MISSING_CONFIGURATION_DATA = _code_from_dict_entry ("4009" )
94
94
RUNTIME_PARAMETER_VALUE_REQUIRED = _code_from_dict_entry ("4010" )
95
+ INCORRECT_API_VERSION = _code_from_dict_entry ("4011" )
95
96
96
97
@classmethod
97
98
@lru_cache (25 )
Original file line number Diff line number Diff line change @@ -921,6 +921,30 @@ def __init__(
921
921
)
922
922
923
923
924
+ class IncorrectAPIVersion (GeneralError ):
925
+ """An error indicating that a command was issued that is not supported by the API version in use."""
926
+
927
+ def __init (
928
+ self ,
929
+ api_element : str ,
930
+ until_version : str ,
931
+ message : Optional [str ] = None ,
932
+ detail : Optional [Dict [str , str ]] = None ,
933
+ wrapping : Optional [Sequence [EnumeratedError ]] = None ,
934
+ ) -> None :
935
+ """Build an IncorrectAPIVersion error."""
936
+ checked_detail : Dict [str , Any ] = detail or {}
937
+ checked_detail ["identifier" ] = api_element
938
+ checked_detail ["until_version" ] = until_version
939
+ checked_message = (
940
+ message
941
+ or f"{ api_element } is not available until version { until_version } ."
942
+ )
943
+ super ().__init__ (
944
+ ErrorCodes .INCORRECT_API_VERSION , checked_message , checked_detail , wrapping
945
+ )
946
+
947
+
924
948
class CommandPreconditionViolated (GeneralError ):
925
949
"""An error indicating that a command was issued in a robot state incompatible with it."""
926
950
You can’t perform that action at this time.
0 commit comments