Account without access Error handling. (#35)
Browse files- src/EdgeGPT.py +7 -1
src/EdgeGPT.py
CHANGED
@@ -13,6 +13,10 @@ import websockets.client as websockets
|
|
13 |
DELIMITER = "\x1e"
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
16 |
def append_identifier(msg: dict) -> str:
|
17 |
"""
|
18 |
Appends special character to end of message to identify end of message
|
@@ -141,7 +145,9 @@ class Conversation:
|
|
141 |
raise Exception("Authentication failed")
|
142 |
try:
|
143 |
self.struct = response.json()
|
144 |
-
|
|
|
|
|
145 |
raise Exception(
|
146 |
"Authentication failed. You have not been accepted into the beta.",
|
147 |
) from exc
|
|
|
13 |
DELIMITER = "\x1e"
|
14 |
|
15 |
|
16 |
+
class NotAllowedToAccess(Exception):
|
17 |
+
pass
|
18 |
+
|
19 |
+
|
20 |
def append_identifier(msg: dict) -> str:
|
21 |
"""
|
22 |
Appends special character to end of message to identify end of message
|
|
|
145 |
raise Exception("Authentication failed")
|
146 |
try:
|
147 |
self.struct = response.json()
|
148 |
+
if self.struct["result"]["value"] == "UnauthorizedRequest":
|
149 |
+
raise NotAllowedToAccess(self.struct["result"]["message"])
|
150 |
+
except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc:
|
151 |
raise Exception(
|
152 |
"Authentication failed. You have not been accepted into the beta.",
|
153 |
) from exc
|