Skip to content

Commit 2cf797b

Browse files
committed
Improve error logging for Microauth
1 parent f943c47 commit 2cf797b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/scaup/auth/micro.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from json import JSONDecodeError
12
from typing import List, TypeVar
23

34
import requests
@@ -46,7 +47,11 @@ def _get_user(token: str):
4647
)
4748

4849
if response.status_code != 200:
49-
raise HTTPException(status_code=response.status_code, detail=response.json().get("detail"))
50+
try:
51+
raise HTTPException(status_code=response.status_code, detail=response.json().get("detail"))
52+
except JSONDecodeError:
53+
app_logger.error(f"Microauth returned {response.status_code}: {response.text}")
54+
raise HTTPException(status_code=response.status_code, detail="Failed to fetch user info from Microauth")
5055
return response.json()
5156

5257

0 commit comments

Comments
 (0)