Skip to content

Commit 34a1219

Browse files
committed
improved error handling in checker
1 parent fdc7927 commit 34a1219

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

checker/src/checker.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def register_user(self, username: str, password: str) -> Tuple[int, int]:
115115
raise MumbleException(f"HTTP error during user registration.")
116116
except Exception as e:
117117
self.logger.error(f"Error during user registration: {e}")
118-
raise MumbleException(f"Error during user registration: {e}")
118+
raise MumbleException(f"Error during user registration.")
119119

120120
async def login_user(self, username: str, password: str, set_token: bool = True) -> str:
121121
self.logger.debug(f"Logging in user: {username}")
@@ -184,10 +184,10 @@ async def import_session(self, session_id: int) -> int:
184184
raise MumbleException(f"Connection error during importing session.")
185185
except HTTPStatusError as e:
186186
self.logger.error(f"HTTPStatusError error during importing session with id {session_id}: {e}")
187-
raise MumbleException(f"HTTPStatusError error during importing session with id {session_id}: {e}")
187+
raise MumbleException(f"HTTPStatusError error during importing session.")
188188
except Exception as e:
189189
self.logger.error(f"Error during importing session with id {session_id}: {e}")
190-
raise MumbleException(f"Error during importing session with id {session_id}: {e}")
190+
raise MumbleException(f"Error during importing session.")
191191

192192
async def search_collection(self, chat_session_id: int, query: str, top_k: int = 1, token: str = None) -> list:
193193
self.logger.debug(f"Searching chat session {chat_session_id} docs with query: {query}")
@@ -214,7 +214,7 @@ async def search_collection(self, chat_session_id: int, query: str, top_k: int =
214214
return documents
215215
except (ConnectTimeout, NetworkError, PoolTimeout, RequestError) as e:
216216
self.logger.error(f"Connection error during searching chat session {chat_session_id} with query {query}: {e}")
217-
raise MumbleException(f"Connection error during chat session search-")
217+
raise MumbleException(f"Connection error during chat session search.")
218218
except HTTPStatusError as e:
219219
self.logger.error(f"HTTP error during searching chat session {chat_session_id} with query {query}: {e}")
220220
raise MumbleException(f"HTTP error during chat session search.")
@@ -394,22 +394,14 @@ async def _run_session(self, read_stream, write_stream, chat_session_id):
394394
async def call_tool(self, tool_name: str, arguments: dict[str, Any] | None = None):
395395
self.logger.debug(f"Calling mcp tool {tool_name} with arguments {arguments}")
396396
if not self.session:
397-
self.logger.error(f"Mcp session was established")
398-
raise MumbleException("Mcp session was established")
397+
self.logger.error(f"Mcp session was not established")
398+
raise MumbleException("Mcp session was not established")
399399

400400
messages = []
401401

402-
try:
403-
result = await self.session.call_tool(tool_name, arguments or {})
404-
if hasattr(result, "content") and len(result.content) == 1 and hasattr(result.content[0], "text"):
405-
messages = json.loads(result.content[0].text)
406-
except Exception as e:
407-
self.logger.error(f"Failed to call mcp tool {tool_name}: {e}")
408-
raise MumbleException(f"Failed to call mcp tool.")
409-
410-
if len(messages) == 0:
411-
self.logger.error(f"MCP GetMessages response is empty for tool {tool_name} with arguments {arguments}")
412-
raise MumbleException(f"Mcp response is empty.")
402+
result = await self.session.call_tool(tool_name, arguments or {})
403+
if hasattr(result, "content") and len(result.content) == 1 and hasattr(result.content[0], "text"):
404+
messages = json.loads(result.content[0].text)
413405

414406
self.logger.debug(f"Received messages {json.dumps(messages)} from tool {tool_name}")
415407
return messages

0 commit comments

Comments
 (0)