diff --git a/src/zinolib/controllers/zino1.py b/src/zinolib/controllers/zino1.py index 1257ff0..e6a3d75 100644 --- a/src/zinolib/controllers/zino1.py +++ b/src/zinolib/controllers/zino1.py @@ -73,7 +73,7 @@ from ..compat import StrEnum from ..event_types import EventType, Event, HistoryEntry, LogEntry, AdmState from ..event_types import PortStateEvent -from ..ritz import ZinoError, ritz, notifier +from ..ritz import ZinoError, ProtocolError, ritz, notifier from ..utils import log_exception_with_params @@ -297,7 +297,10 @@ def set_admin_state(request, event: EventType, state: AdmState) -> bool: @staticmethod def get_event_ids(request): - return request.get_caseids() + try: + return request.get_caseids() + except ProtocolError as e: + raise RetryError('Zino 1 failed to send a correct response header, retry') from e class HistoryAdapter: @@ -400,7 +403,7 @@ def parse_response(log_data: Iterable[str]) -> list[LogDict]: try: timestamp = int(timestamp) except ValueError as e: - raise RetryError('Zino 1 is flaking out, retry') from e + raise RetryError('Zino 1 did not send a log, retry') from e dt = convert_timestamp(timestamp) log_list.append({"date": dt, "log": log}) return log_list @@ -485,7 +488,7 @@ def create_event_from_id(self, event_id: int): self._verify_session() attrlist = self.rename_exception(self._event_adapter.get_attrlist, self.session.request, event_id) if not self._event_adapter.validate_raw_attrlist(attrlist): - raise RetryError('Zino 1 is flaking out, retry') + raise RetryError('Zino 1 did not send event attributes, retry') attrdict = self._event_adapter.attrlist_to_attrdict(attrlist) attrdict = self._event_adapter.convert_values(attrdict) return Event.create(attrdict) diff --git a/src/zinolib/ritz.py b/src/zinolib/ritz.py index 1352d84..7346c5f 100644 --- a/src/zinolib/ritz.py +++ b/src/zinolib/ritz.py @@ -391,10 +391,10 @@ def _request(self, command: bytes, recv_buffer=4096, **_): line, buffer = buffer.split(self.DELIMITER, 1) rawh = line.split(" ", 1) # ' ' is not a byte header = (int(rawh[0]), rawh[1]) - except ValueError: + except ValueError as e: raise ProtocolError( "Illegal response from server detected: %s" % repr(buffer) - ) + ) from e # header = line # Crude error detection :) if header[0] >= 500: