diff --git a/bfxapi/exceptions.py b/bfxapi/_exceptions.py similarity index 63% rename from bfxapi/exceptions.py rename to bfxapi/_exceptions.py index b636119..e408bd6 100644 --- a/bfxapi/exceptions.py +++ b/bfxapi/_exceptions.py @@ -1,7 +1,3 @@ -__all__ = [ - "BfxBaseException", -] - class BfxBaseException(Exception): """ Base class for every custom exception in bfxapi/rest/exceptions.py and bfxapi/websocket/exceptions.py. @@ -11,3 +7,8 @@ class IncompleteCredentialError(BfxBaseException): """ This error indicates an incomplete credential object (missing api-key or api-secret). """ + +class InvalidCredentialError(BfxBaseException): + """ + This error indicates that the user has provided incorrect credentials (API-KEY and API-SECRET) for authentication. + """ diff --git a/bfxapi/rest/exceptions.py b/bfxapi/rest/exceptions.py index 0c506d1..ab7001c 100644 --- a/bfxapi/rest/exceptions.py +++ b/bfxapi/rest/exceptions.py @@ -1,35 +1,17 @@ -from ..exceptions import BfxBaseException +# pylint: disable-next=wildcard-import,unused-wildcard-import +from bfxapi._exceptions import * -__all__ = [ - "BfxRestException", - - "ResourceNotFound", - "RequestParametersError", - "ResourceNotFound", - "InvalidAuthenticationCredentials" -] - -class BfxRestException(BfxBaseException): - """ - Base class for all custom exceptions in bfxapi/rest/exceptions.py. - """ - -class ResourceNotFound(BfxRestException): +class ResourceNotFound(BfxBaseException): """ This error indicates a failed HTTP request to a non-existent resource. """ -class RequestParametersError(BfxRestException): +class RequestParametersError(BfxBaseException): """ This error indicates that there are some invalid parameters sent along with an HTTP request. """ -class InvalidAuthenticationCredentials(BfxRestException): - """ - This error indicates that the user has provided incorrect credentials (API-KEY and API-SECRET) for authentication. - """ - -class UnknownGenericError(BfxRestException): +class UnknownGenericError(BfxBaseException): """ This error indicates an undefined problem processing an HTTP request sent to the APIs. """ diff --git a/bfxapi/websocket/exceptions.py b/bfxapi/websocket/exceptions.py index c23da60..1720122 100644 --- a/bfxapi/websocket/exceptions.py +++ b/bfxapi/websocket/exceptions.py @@ -1,65 +1,47 @@ -from ..exceptions import BfxBaseException +# pylint: disable-next=wildcard-import,unused-wildcard-import +from bfxapi._exceptions import * -__all__ = [ - "BfxWebSocketException", - - "ConnectionNotOpen", - "FullBucketError", - "ZeroConnectionsError", - "ReconnectionTimeoutError", - "ActionRequiresAuthentication", - "InvalidAuthenticationCredentials", - "UnknownChannelError", - "UnknownEventError", - "OutdatedClientVersion" -] - -class BfxWebSocketException(BfxBaseException): - """ - Base class for all custom exceptions in bfxapi/websocket/exceptions.py. - """ - -class ConnectionNotOpen(BfxWebSocketException): +class ConnectionNotOpen(BfxBaseException): """ This error indicates an attempt to communicate via websocket before starting the connection with the servers. """ -class FullBucketError(BfxWebSocketException): +class FullBucketError(BfxBaseException): """ Thrown when a user attempts a subscription but all buckets are full. """ -class ZeroConnectionsError(BfxWebSocketException): +class ZeroConnectionsError(BfxBaseException): """ This error indicates an attempt to subscribe to a public channel while the number of connections is 0. """ -class ReconnectionTimeoutError(BfxWebSocketException): +class ReconnectionTimeoutError(BfxBaseException): """ This error indicates that the connection has been offline for too long without being able to reconnect. """ -class ActionRequiresAuthentication(BfxWebSocketException): +class ActionRequiresAuthentication(BfxBaseException): """ This error indicates an attempt to access a protected resource without logging in first. """ -class InvalidAuthenticationCredentials(BfxWebSocketException): - """ - This error indicates that the user has provided incorrect credentials (API-KEY and API-SECRET) for authentication. - """ - -class UnknownChannelError(BfxWebSocketException): +class UnknownChannelError(BfxBaseException): """ Thrown when a user attempts to subscribe to an unknown channel. """ -class UnknownEventError(BfxWebSocketException): +class UnknownSubscriptionError(BfxBaseException): + """ + Thrown when a user attempts to reference an unknown subscription. + """ + +class UnknownEventError(BfxBaseException): """ Thrown when a user attempts to add a listener for an unknown event. """ -class OutdatedClientVersion(BfxWebSocketException): +class VersionMismatchError(BfxBaseException): """ This error indicates a mismatch between the client version and the server WSS version. """