Rename bfxapi/websocket/errors.py to exceptions.py. Add Errors enumeration inside BfxWebsocketClient.py and bfxapi/websocket/__init__.py.

This commit is contained in:
Davide Casale
2022-11-22 18:11:05 +01:00
parent 999766a307
commit a8dec5c6bc
5 changed files with 25 additions and 6 deletions

View File

@@ -1,10 +1,12 @@
import json, asyncio, hmac, hashlib, time, uuid, websockets
from enum import Enum
from pyee.asyncio import AsyncIOEventEmitter
from .handlers import Channels, PublicChannelsHandler, AuthenticatedChannelsHandler
from .errors import ConnectionNotOpen, TooManySubscriptions, WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, OutdatedClientVersion
from .exceptions import ConnectionNotOpen, TooManySubscriptions, WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, OutdatedClientVersion
HEARTBEAT = "hb"
@@ -191,4 +193,21 @@ class _BfxWebsocketBucket(object):
@_require_websocket_connection
async def close(self, code=1000, reason=str()):
await self.websocket.close(code=code, reason=reason)
await self.websocket.close(code=code, reason=reason)
class Errors(int, Enum):
ERR_UNK = 10000
ERR_GENERIC = 10001
ERR_CONCURRENCY = 10008
ERR_PARAMS = 10020
ERR_CONF_FAIL = 10050
ERR_AUTH_FAIL = 10100
ERR_AUTH_PAYLOAD = 10111
ERR_AUTH_SIG = 10112
ERR_AUTH_HMAC = 10113
ERR_AUTH_NONCE = 10114
ERR_UNAUTH_FAIL = 10200
ERR_SUB_FAIL = 10300
ERR_SUB_MULTI = 10301
ERR_UNSUB_FAIL = 10400
ERR_READY = 11000