vip11017 commited on
Commit
9bdf7ef
·
1 Parent(s): 5e0d69f

added try statement to starred chats

Browse files
Files changed (1) hide show
  1. app/routers/chats.py +11 -9
app/routers/chats.py CHANGED
@@ -74,14 +74,16 @@ async def get_starred_chats():
74
  """
75
  Returns all chat logs that are starred
76
  """
 
 
 
 
 
 
 
 
77
 
78
- chats_cursor = chat_logs.find({"starred": True}).sort("timestamp", -1)
79
- starred_chats = await chats_cursor.to_list(length=None)
80
 
81
- if not starred_chats:
82
- starred_chats = []
83
-
84
- for chat in starred_chats:
85
- chat['id'] = str(chat['_id'])
86
- del chat['_id']
87
- return starred_chats
 
74
  """
75
  Returns all chat logs that are starred
76
  """
77
+ try:
78
+ chats_cursor = chat_logs.find({"starred": True}).sort("timestamp", -1)
79
+ starred_chats = await chats_cursor.to_list(length=None)
80
+
81
+ for chat in starred_chats:
82
+ chat['id'] = str(chat['_id'])
83
+ del chat['_id']
84
+ return starred_chats
85
 
 
 
86
 
87
+ except Exception as e:
88
+ raise HTTPException(status_code=404, detail="No Starred Chat Logs found")
89
+