diff --git a/bfxapi/exceptions.py b/bfxapi/exceptions.py new file mode 100644 index 0000000..8e9b6e5 --- /dev/null +++ b/bfxapi/exceptions.py @@ -0,0 +1,18 @@ +__all__ = [ + "BfxBaseException", + "LabelerSerializerException" +] + +class BfxBaseException(Exception): + """ + Base class for every custom exception in bfxapi/rest/exceptions.py and bfxapi/websocket/exceptions.py. + """ + + pass + +class LabelerSerializerException(BfxBaseException): + """ + This exception indicates an error thrown by the _Serializer class in bfxapi/labeler.py. + """ + + pass \ No newline at end of file diff --git a/bfxapi/labeler.py b/bfxapi/labeler.py index eb7076c..d358ffd 100644 --- a/bfxapi/labeler.py +++ b/bfxapi/labeler.py @@ -1,3 +1,5 @@ +from .exceptions import LabelerSerializerException + from typing import Generic, TypeVar, Iterable, Optional, List, Any T = TypeVar("T") @@ -10,7 +12,7 @@ class _Serializer(Generic[T]): labels = list(filter(lambda label: label not in (skip or list()), self.__labels)) if len(labels) > len(args): - raise Exception(" and <*args> arguments should contain the same amount of elements.") + raise LabelerSerializerException(" and <*args> arguments should contain the same amount of elements.") for index, label in enumerate(labels): if label not in self.__IGNORE: diff --git a/bfxapi/rest/exceptions.py b/bfxapi/rest/exceptions.py index 973fb5a..0fc6de8 100644 --- a/bfxapi/rest/exceptions.py +++ b/bfxapi/rest/exceptions.py @@ -1,12 +1,16 @@ +from ..exceptions import BfxBaseException + __all__ = [ + "BfxRestException", + "RequestParametersError", "ResourceNotFound", "InvalidAuthenticationCredentials" ] -class BfxRestException(Exception): +class BfxRestException(BfxBaseException): """ - Base class for all exceptions defined in bfxapi/rest/exceptions.py. + Base class for all custom exceptions in bfxapi/rest/exceptions.py. """ pass