Documentation
¶
Index ¶
- func IsCode(err error, code ErrorCode) bool
- type AIError
- func AgentExecutionFailed(msg string, cause error) *AIError
- func AgentNotFound(agentType string) *AIError
- func ContextCanceled(cause error) *AIError
- func InvalidArgument(msg string) *AIError
- func LLMUnavailable(msg string) *AIError
- func RateLimitExceeded(msg string) *AIError
- func ServiceUnavailable(msg string) *AIError
- func Timeout(msg string) *AIError
- func Unauthorized(msg string) *AIError
- func Wrap(cause error, code ErrorCode, msg string) *AIError
- type ErrorCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIError ¶
AIError represents a structured error for AI operations.
func AgentExecutionFailed ¶
AgentExecutionFailed creates an agent execution failed error.
func AgentNotFound ¶
AgentNotFound creates an agent not found error.
func ContextCanceled ¶
ContextCanceled creates a context canceled error.
func InvalidArgument ¶
InvalidArgument creates an invalid argument error.
func LLMUnavailable ¶
LLMUnavailable creates an LLM unavailable error.
func RateLimitExceeded ¶
RateLimitExceeded creates a rate limit exceeded error.
func ServiceUnavailable ¶
ServiceUnavailable creates a service unavailable error.
func Unauthorized ¶
Unauthorized creates an unauthorized error.
func (*AIError) WithContext ¶
WithContext adds context to the error.
func (*AIError) WithContextMap ¶
WithContextMap adds multiple context values to the error.
type ErrorCode ¶
type ErrorCode string
ErrorCode represents a specific error type for AI operations.
const ( ErrCodeUnauthorized ErrorCode = "UNAUTHORIZED" // ErrCodeRateLimitExceeded indicates rate limit has been exceeded. ErrCodeRateLimitExceeded ErrorCode = "RATE_LIMIT_EXCEEDED" // ErrCodeInvalidArgument indicates invalid input parameters. ErrCodeInvalidArgument ErrorCode = "INVALID_ARGUMENT" ErrCodeServiceUnavailable ErrorCode = "SERVICE_UNAVAILABLE" // ErrCodeAgentExecutionFailed indicates agent execution failure. ErrCodeAgentExecutionFailed ErrorCode = "AGENT_EXECUTION_FAILED" // ErrCodeAgentNotFound indicates the requested agent type does not exist. ErrCodeAgentNotFound ErrorCode = "AGENT_NOT_FOUND" ErrCodeLLMUnavailable ErrorCode = "LLM_UNAVAILABLE" // ErrCodeContextCanceled indicates the operation was canceled. ErrCodeContextCanceled ErrorCode = "CONTEXT_CANCELED" // ErrCodeTimeout indicates the operation timed out. ErrCodeTimeout ErrorCode = "TIMEOUT" )
func GetCodeFromError ¶
GetCodeFromError extracts the error code from any error. Returns the provided default code if the error is not an AIError.