From f4dbbe61f89d8d4a1753058c5d69cc71467213d4 Mon Sep 17 00:00:00 2001 From: "Walter C. Pettus" Date: Fri, 6 Dec 2024 17:16:39 -0500 Subject: [PATCH] Fix raise error convention --- dripline/core/calibrate.py | 6 ++---- dripline/implementations/entity_endpoints.py | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dripline/core/calibrate.py b/dripline/core/calibrate.py index f0da80b8..2f9254c2 100644 --- a/dripline/core/calibrate.py +++ b/dripline/core/calibrate.py @@ -4,8 +4,6 @@ # optional only when doing a docs build pass -#TODO need to put exceptions back, this is fragile/wrong right now -#from . import exceptions __all__ = [] @@ -47,7 +45,7 @@ def wrapper(self, *args, **kwargs): logger.debug('GOT AN OVERFLOW ERROR') cal = None except Exception as e: - raise exceptions.DriplineValueError(repr(e), result=val_dict) + raise ValueError(repr(e)) if cal is not None: val_dict['value_cal'] = cal elif isinstance(self._calibration, dict): @@ -55,7 +53,7 @@ def wrapper(self, *args, **kwargs): if val_dict['value_raw'] in self._calibration: val_dict['value_cal'] = self._calibration[val_dict['value_raw']] else: - raise exceptions.DriplineValueError(f"raw value <{repr(val_dict['value_raw'])}> not in cal dict", result=val_dict) + raise ValueError(f"raw value <{repr(val_dict['value_raw'])}> not in cal dict) else: logger.warning('the _calibration property is of unknown type') return val_dict diff --git a/dripline/implementations/entity_endpoints.py b/dripline/implementations/entity_endpoints.py index d6b4ddcc..292798d7 100644 --- a/dripline/implementations/entity_endpoints.py +++ b/dripline/implementations/entity_endpoints.py @@ -137,8 +137,7 @@ def on_get(self): matches = re.search(self._extract_raw_regex, first_result) if matches is None: logger.error('matching returned none') - # exceptions.DriplineValueError - raise ThrowReply('resource_error', 'device returned unparsable result, [{}] has no match to input regex [{}]'.format(first_result, self._extract_raw_regex)) + raise ValueError('device returned unparsable result, [{}] has no match to input regex [{}]'.format(first_result, self._extract_raw_regex)) logger.debug(f"matches are: {matches.groupdict()}") result = matches.groupdict()['value_raw'] return result @@ -146,7 +145,7 @@ def on_get(self): def on_set(self, value): if self._set_str is None: # exceptions.DriplineMethodNotSupportedError - raise ThrowReply('service_error', f"endpoint '{self.name}' does not support set") + raise ThrowReply('message_error_invalid_method', f"endpoint '{self.name}' does not support set") if isinstance(value, str) and self._set_value_lowercase: value = value.lower() if self._set_value_map is None: