Skip to content

Commit e157b38

Browse files
committed
[Community] make community auth error clearer
1 parent 86a34c3 commit e157b38

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

octobot/community/supabase_backend/community_supabase_client.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def sign_in(self, email: str, password: str) -> None:
9999
if "email" in str(err).lower():
100100
# AuthApiError('Email not confirmed')
101101
raise errors.EmailValidationRequiredError(err) from err
102-
raise authentication.FailedAuthentication(err) from err
102+
raise authentication.FailedAuthentication(f"Community auth error: {err}") from err
103103

104104
async def sign_up(self, email: str, password: str) -> None:
105105
try:
@@ -117,7 +117,7 @@ async def sign_up(self, email: str, password: str) -> None:
117117
if self._requires_email_validation(resp.user):
118118
raise errors.EmailValidationRequiredError()
119119
except gotrue.errors.AuthError as err:
120-
raise authentication.AuthenticationError(err) from err
120+
raise authentication.AuthenticationError(f"Community auth error: {err}") from err
121121

122122
async def sign_out(self, options: gotrue.types.SignOutOptions) -> None:
123123
try:
@@ -132,13 +132,13 @@ async def restore_session(self):
132132
self.event_loop = asyncio.get_event_loop()
133133
await self.auth.initialize_from_storage()
134134
if not self.is_signed_in():
135-
raise authentication.FailedAuthentication()
135+
raise authentication.FailedAuthentication(f"Community auth error: restoring session failed")
136136

137137
async def refresh_session(self, refresh_token: typing.Union[str, None] = None):
138138
try:
139139
await self.auth.refresh_session(refresh_token=refresh_token)
140140
except gotrue.errors.AuthError as err:
141-
raise authentication.AuthenticationError(err) from err
141+
raise authentication.AuthenticationError(f"Community auth error: {err}") from err
142142

143143
async def sign_in_with_otp_token(self, token):
144144
self.event_loop = asyncio.get_event_loop()
@@ -156,7 +156,7 @@ async def sign_in_with_otp_token(self, token):
156156
except gotrue.errors.AuthImplicitGrantRedirectError as err:
157157
if saved_session:
158158
await self.auth._storage.set_item(self.auth._storage_key, saved_session)
159-
raise authentication.AuthenticationError(err) from err
159+
raise authentication.AuthenticationError(f"Community auth error: {err}") from err
160160

161161
def is_signed_in(self) -> bool:
162162
# is signed in when a user auth key is set
@@ -201,7 +201,7 @@ async def get_otp_with_auth_key(self, user_email: str, auth_key: str) -> str:
201201
)
202202
return json.loads(resp)["token"]
203203
except Exception:
204-
raise authentication.AuthenticationError(f"Invalid auth key authentication details")
204+
raise authentication.AuthenticationError(f"Community auth error: invalid auth key authentication details")
205205

206206
async def fetch_extensions(self, mqtt_uuid: typing.Optional[str]) -> dict:
207207
resp = await self.functions.invoke(

0 commit comments

Comments
 (0)