diff --git a/auraxium/__init__.py b/auraxium/__init__.py index 6fbd8cf..ab9bbcb 100644 --- a/auraxium/__init__.py +++ b/auraxium/__init__.py @@ -34,4 +34,4 @@ ] __author__ = 'Leonhard S.' -__version__ = '0.2.0b2' +__version__ = '0.2.0b3' diff --git a/auraxium/base.py b/auraxium/base.py index 76181a9..36875c5 100644 --- a/auraxium/base.py +++ b/auraxium/base.py @@ -79,6 +79,12 @@ def __init__(self, data: CensusData, client: RequestClient) -> None: try: self.data = self._model(**data) except pydantic.ValidationError as err: + _log.warning( + 'Encountered unsupported payload: %s\n' + 'This message means that the Auraxium data model must ' + 'be updated. Please ensure you are on the latest ' + 'version of the Auraxium library and report this ' + 'message to the project maintainers.', data) raise PayloadError( f'Unable to instantiate {self.__class__.__name__} instance ' f'from given payload: {err}', data) from err diff --git a/auraxium/event/_client.py b/auraxium/event/_client.py index d922cdd..dea3b63 100644 --- a/auraxium/event/_client.py +++ b/auraxium/event/_client.py @@ -5,6 +5,7 @@ from typing import (Any, Callable, Coroutine, Dict, Iterator, List, Optional, Type, TypeVar, Union, cast, overload) import backoff +import pydantic import websockets @@ -376,7 +377,16 @@ def _process_payload(self, response: str) -> None: # Event messages if service == 'event': if data['type'] == 'serviceMessage': - event = _event_factory(cast(CensusData, data['payload'])) + try: + event = _event_factory(cast(CensusData, data['payload'])) + except pydantic.ValidationError: + _log.warning( + 'Ignoring unsupported payload: %s\n' + 'This message means that the Auraxium data model must ' + 'be updated. Please ensure you are on the latest ' + 'version of the Auraxium library and report this ' + 'message to the project maintainers.', data['payload']) + return _log.debug('%s event received, dispatching...', event.event_name) self.dispatch(event)