Documentation
¶
Index ¶
- type ClassifiedError
- type ErrorCategory
- type ErrorClassifier
- type ErrorHandler
- func (eh *ErrorHandler) CreateUserFriendlyError(classified *ClassifiedError) error
- func (eh *ErrorHandler) FormatErrorForJSON(classified *ClassifiedError) map[string]interface{}
- func (eh *ErrorHandler) GetErrorReport() map[string]interface{}
- func (eh *ErrorHandler) GetRetryDelay(classified *ClassifiedError, attempt int) time.Duration
- func (eh *ErrorHandler) GetStatistics() *ErrorStatistics
- func (eh *ErrorHandler) HandleError(ctx context.Context, err error, operation string, ...) *ClassifiedError
- func (eh *ErrorHandler) HandleErrorWithRetry(ctx context.Context, err error, operation string, ...) (*ClassifiedError, bool)
- func (eh *ErrorHandler) ResetStatistics()
- type ErrorSeverity
- type ErrorStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClassifiedError ¶
type ClassifiedError struct {
Category ErrorCategory
Severity ErrorSeverity
Message string
Cause error
Context map[string]interface{}
Recoverable bool
RetryAfter *time.Duration
}
ClassifiedError represents an error with classification metadata
func (*ClassifiedError) Error ¶
func (e *ClassifiedError) Error() string
func (*ClassifiedError) Is ¶
func (e *ClassifiedError) Is(target error) bool
func (*ClassifiedError) Unwrap ¶
func (e *ClassifiedError) Unwrap() error
type ErrorCategory ¶
type ErrorCategory int
ErrorCategory represents different types of MCP errors
const ( // Connection errors CategoryConnection ErrorCategory = iota CategoryTransport CategoryTimeout CategoryAuthentication // Protocol errors CategoryProtocol CategorySerialization CategoryValidation // Server errors CategoryServerStartup CategoryServerInternal CategoryServerCapability // Client errors CategoryClientConfig CategoryClientUsage CategoryClientResource // Unknown errors CategoryUnknown )
func (ErrorCategory) String ¶
func (c ErrorCategory) String() string
type ErrorClassifier ¶
type ErrorClassifier struct{}
ErrorClassifier provides error classification and analysis
func NewErrorClassifier ¶
func NewErrorClassifier() *ErrorClassifier
NewErrorClassifier creates a new error classifier
func (*ErrorClassifier) Classify ¶
func (ec *ErrorClassifier) Classify(err error, context map[string]interface{}) *ClassifiedError
Classify analyzes an error and returns a classified error with metadata
func (*ErrorClassifier) GetRecoveryActions ¶
func (ec *ErrorClassifier) GetRecoveryActions(classified *ClassifiedError) []string
GetRecoveryActions returns suggested recovery actions for an error
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
ErrorHandler provides centralized error handling with classification and reporting
func NewErrorHandler ¶
func NewErrorHandler() *ErrorHandler
NewErrorHandler creates a new error handler with classification
func (*ErrorHandler) CreateUserFriendlyError ¶
func (eh *ErrorHandler) CreateUserFriendlyError(classified *ClassifiedError) error
CreateUserFriendlyError creates a user-friendly error message with recovery suggestions
func (*ErrorHandler) FormatErrorForJSON ¶
func (eh *ErrorHandler) FormatErrorForJSON(classified *ClassifiedError) map[string]interface{}
FormatErrorForJSON formats a classified error for JSON serialization
func (*ErrorHandler) GetErrorReport ¶
func (eh *ErrorHandler) GetErrorReport() map[string]interface{}
GetErrorReport generates a detailed error report
func (*ErrorHandler) GetRetryDelay ¶
func (eh *ErrorHandler) GetRetryDelay(classified *ClassifiedError, attempt int) time.Duration
GetRetryDelay returns the delay before next retry attempt
func (*ErrorHandler) GetStatistics ¶
func (eh *ErrorHandler) GetStatistics() *ErrorStatistics
GetStatistics returns current error statistics
func (*ErrorHandler) HandleError ¶
func (eh *ErrorHandler) HandleError(ctx context.Context, err error, operation string, context map[string]interface{}) *ClassifiedError
HandleError processes an error with full classification and logging
func (*ErrorHandler) HandleErrorWithRetry ¶
func (eh *ErrorHandler) HandleErrorWithRetry(ctx context.Context, err error, operation string, context map[string]interface{}, attempt int) (*ClassifiedError, bool)
HandleErrorWithRetry handles an error and provides retry logic if appropriate
func (*ErrorHandler) ResetStatistics ¶
func (eh *ErrorHandler) ResetStatistics()
ResetStatistics clears error statistics
type ErrorSeverity ¶
type ErrorSeverity int
ErrorSeverity represents the severity level of an error
const ( SeverityInfo ErrorSeverity = iota SeverityWarning SeverityError SeverityCritical )
func (ErrorSeverity) String ¶
func (s ErrorSeverity) String() string
type ErrorStatistics ¶
type ErrorStatistics struct {
TotalErrors int `json:"total_errors"`
ErrorsByCategory map[ErrorCategory]int `json:"errors_by_category"`
ErrorsBySeverity map[ErrorSeverity]int `json:"errors_by_severity"`
RecoverableErrors int `json:"recoverable_errors"`
RetryAttempts int `json:"retry_attempts"`
LastError *ClassifiedError `json:"last_error,omitempty"`
ErrorHistory []*ClassifiedError `json:"error_history,omitempty"`
StartTime time.Time `json:"start_time"`
}
ErrorStatistics tracks error patterns and frequencies