mirror of
https://github.com/HKUDS/OpenSpace.git
synced 2026-09-07 08:25:54 +00:00
fix: replace ErrorCode enum calls with GroundingError raises
ErrorCode is a str Enum whose members are not callable. Calling `raise ErrorCode.SESSION_NOT_FOUND(name)` produces a TypeError instead of the intended session-not-found error. Replace all 5 occurrences with `raise GroundingError(..., code=ErrorCode.SESSION_NOT_FOUND)`. Closes #11 Made-with: Cursor
This commit is contained in:
parent
e80c70e9c9
commit
171c1b76f8
1 changed files with 5 additions and 5 deletions
|
|
@ -337,13 +337,13 @@ class GroundingClient:
|
|||
def get_session_info(self, name: str) -> SessionInfo:
|
||||
"""Get session monitoring info"""
|
||||
if name not in self._session_info:
|
||||
raise ErrorCode.SESSION_NOT_FOUND(name)
|
||||
raise GroundingError(f"Session not found: {name}", code=ErrorCode.SESSION_NOT_FOUND)
|
||||
return self._session_info[name]
|
||||
|
||||
def get_session(self, name: str) -> BaseSession:
|
||||
"""Get session"""
|
||||
if name not in self._sessions:
|
||||
raise ErrorCode.SESSION_NOT_FOUND(name)
|
||||
raise GroundingError(f"Session not found: {name}", code=ErrorCode.SESSION_NOT_FOUND)
|
||||
return self._sessions[name]
|
||||
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ class GroundingClient:
|
|||
# Session-level
|
||||
if session_name:
|
||||
if session_name not in self._sessions:
|
||||
raise ErrorCode.SESSION_NOT_FOUND(session_name)
|
||||
raise GroundingError(f"Session not found: {session_name}", code=ErrorCode.SESSION_NOT_FOUND)
|
||||
backend_type = self._session_info[session_name].backend_type
|
||||
return await self._fetch_tools(
|
||||
backend_type,
|
||||
|
|
@ -531,7 +531,7 @@ class GroundingClient:
|
|||
use_cache: bool = False
|
||||
) -> list[BaseTool]:
|
||||
if session_name not in self._session_info:
|
||||
raise ErrorCode.SESSION_NOT_FOUND(session_name)
|
||||
raise GroundingError(f"Session not found: {session_name}", code=ErrorCode.SESSION_NOT_FOUND)
|
||||
backend = self._session_info[session_name].backend_type
|
||||
return await self.list_tools(backend, session_name, use_cache)
|
||||
|
||||
|
|
@ -838,7 +838,7 @@ class GroundingClient:
|
|||
runtime_backend = backend
|
||||
else:
|
||||
if runtime_session not in self._session_info:
|
||||
raise ErrorCode.SESSION_NOT_FOUND(runtime_session)
|
||||
raise GroundingError(f"Session not found: {runtime_session}", code=ErrorCode.SESSION_NOT_FOUND)
|
||||
runtime_backend = self._session_info[
|
||||
runtime_session
|
||||
].backend_type
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue