We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 97be1f8 commit ee5ebc1Copy full SHA for ee5ebc1
alpaca_trade_api/stream2.py
@@ -39,11 +39,16 @@ async def _connect(self):
39
r = r.decode('utf-8')
40
msg = json.loads(r)
41
42
- if msg.get('data', {}).get('status') != 'authorized':
43
- raise ValueError(
44
- ("Invalid Alpaca API credentials, Failed to authenticate: {}"
45
- .format(msg))
46
- )
+ if msg.get('data', {}).get('status'):
+ status = msg.get('data').get('status')
+ if status != 'authorized':
+ raise ValueError(
+ (f"Invalid Alpaca API credentials, Failed to "
47
+ f"authenticate: {msg}")
48
+ )
49
+ elif msg.get('data', {}).get('error'):
50
+ raise Exception(f"Error while connecting to {self._endpoint}:"
51
+ f"{msg.get('data').get('error')}")
52
else:
53
self._retries = 0
54
0 commit comments