chore: snapshot before HartOMat rebrand
This commit is contained in:
@@ -99,12 +99,21 @@ async def send_message(
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(exc))
|
||||
except Exception as exc:
|
||||
error_msg = str(exc)
|
||||
error_code = None
|
||||
# Extract meaningful error from OpenAI exceptions
|
||||
if hasattr(exc, 'message'):
|
||||
error_msg = exc.message
|
||||
elif hasattr(exc, 'body') and isinstance(exc.body, dict):
|
||||
error_msg = exc.body.get('error', {}).get('message', error_msg)
|
||||
if hasattr(exc, 'body') and isinstance(exc.body, dict):
|
||||
err = exc.body.get('error', {})
|
||||
error_code = err.get('code')
|
||||
error_msg = err.get('message', error_msg)
|
||||
logger.error("Chat error: %s", error_msg)
|
||||
# Content filter violation → return 422 with user-friendly message
|
||||
if error_code == 'content_filter':
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Deine Nachricht wurde vom Azure Content Filter blockiert. Bitte formuliere sie um.",
|
||||
)
|
||||
raise HTTPException(status_code=500, detail=f"AI error: {error_msg[:500]}")
|
||||
except Exception as exc:
|
||||
logger.exception("Chat error for user %s", user.id)
|
||||
|
||||
Reference in New Issue
Block a user