feat: error handling for rest api for agents + blocks [LET-4625] (#5142)
This commit is contained in:
committed by
Caren Thomas
parent
e07a589796
commit
7aff9aa659
@@ -97,6 +97,34 @@ class LettaUserNotFoundError(LettaError):
|
||||
"""Error raised when a user is not found."""
|
||||
|
||||
|
||||
class LettaInvalidArgumentError(LettaError):
|
||||
"""Error raised when an invalid argument is provided."""
|
||||
|
||||
def __init__(self, message: str, argument_name: Optional[str] = None):
|
||||
details = {"argument_name": argument_name} if argument_name else {}
|
||||
super().__init__(message=message, code=ErrorCode.INVALID_ARGUMENT, details=details)
|
||||
|
||||
|
||||
class LettaMCPError(LettaError):
|
||||
"""Base error for MCP-related issues."""
|
||||
|
||||
|
||||
class LettaMCPConnectionError(LettaMCPError):
|
||||
"""Error raised when unable to connect to MCP server."""
|
||||
|
||||
def __init__(self, message: str, server_name: Optional[str] = None):
|
||||
details = {"server_name": server_name} if server_name else {}
|
||||
super().__init__(message=message, code=ErrorCode.INTERNAL_SERVER_ERROR, details=details)
|
||||
|
||||
|
||||
class LettaMCPTimeoutError(LettaMCPError):
|
||||
"""Error raised when MCP server operation times out."""
|
||||
|
||||
def __init__(self, message: str, server_name: Optional[str] = None):
|
||||
details = {"server_name": server_name} if server_name else {}
|
||||
super().__init__(message=message, code=ErrorCode.TIMEOUT, details=details)
|
||||
|
||||
|
||||
class LettaUnexpectedStreamCancellationError(LettaError):
|
||||
"""Error raised when a streaming request is terminated unexpectedly."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user