Documentation
¶
Overview ¶
Package errs provides error context enrichment, grouping, learning, patterns, and recovery for the hawk engine.
Named "errs" (not "error") to avoid shadowing the builtin error type.
Index ¶
- func ExtractPattern(errorMsg string) string
- func FormatError(enriched *EnrichedError) string
- func NormalizeError(msg string) string
- type EnrichedError
- type ErrorContext
- type ErrorGroup
- type ErrorGrouper
- func (eg *ErrorGrouper) Add(errorMsg, file string, line int, context string) *ErrorGroup
- func (eg *ErrorGrouper) FindGroup(errorMsg string) *ErrorGroup
- func (eg *ErrorGrouper) FormatGroups() string
- func (eg *ErrorGrouper) GetActive() []*ErrorGroup
- func (eg *ErrorGrouper) GetResolution(errorMsg string) string
- func (eg *ErrorGrouper) IsKnown(errorMsg string) bool
- func (eg *ErrorGrouper) MarkResolved(groupID, resolution string)
- func (eg *ErrorGrouper) Prune(maxAge time.Duration)
- type ErrorHelp
- type ErrorInstance
- type ErrorLearner
- func (el *ErrorLearner) BuildFixSuggestion(errorMsg string) string
- func (el *ErrorLearner) Export() ([]byte, error)
- func (el *ErrorLearner) Import(data []byte) error
- func (el *ErrorLearner) Learn(errorMsg, fix, language, category string)
- func (el *ErrorLearner) MatchLearned(errorMsg string) []*LearnedPattern
- func (el *ErrorLearner) PruneWeak(minConfidence float64)
- func (el *ErrorLearner) RecordFailure(patternID string)
- func (el *ErrorLearner) RecordSuccess(patternID string)
- func (el *ErrorLearner) Stats() ErrorLearnerStats
- type ErrorLearnerStats
- type ErrorPattern
- type ErrorPatternDB
- type ErrorRecovery
- func (er *ErrorRecovery) BuildRecoveryPrompt(result *RecoveryResult) string
- func (er *ErrorRecovery) FormatHistory(limit int) string
- func (er *ErrorRecovery) Recover(err error, ctx *RecoveryContext) (*RecoveryResult, error)
- func (er *ErrorRecovery) RegisterStrategy(strategy *RecoveryStrategy)
- func (er *ErrorRecovery) ShouldRetry(err error) bool
- func (er *ErrorRecovery) SuccessRate() float64
- type LearnedPattern
- type RecoveryAttempt
- type RecoveryContext
- type RecoveryResult
- type RecoveryStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPattern ¶
func FormatError ¶
func FormatError(enriched *EnrichedError) string
func NormalizeError ¶
Types ¶
type EnrichedError ¶
type ErrorContext ¶
type ErrorContext struct {
Patterns map[string]*ErrorHelp
// contains filtered or unexported fields
}
func NewErrorContext ¶
func NewErrorContext() *ErrorContext
func (*ErrorContext) AddPattern ¶
func (ec *ErrorContext) AddPattern(pattern string, help ErrorHelp) error
func (*ErrorContext) Enrich ¶
func (ec *ErrorContext) Enrich(err string) *EnrichedError
func (*ErrorContext) IsRecoverable ¶
func (ec *ErrorContext) IsRecoverable(err string) bool
func (*ErrorContext) SuggestFix ¶
func (ec *ErrorContext) SuggestFix(err string) string
type ErrorGroup ¶
type ErrorGrouper ¶
type ErrorGrouper struct {
Groups map[string]*ErrorGroup
// contains filtered or unexported fields
}
func NewErrorGrouper ¶
func NewErrorGrouper() *ErrorGrouper
func (*ErrorGrouper) Add ¶
func (eg *ErrorGrouper) Add(errorMsg, file string, line int, context string) *ErrorGroup
func (*ErrorGrouper) FindGroup ¶
func (eg *ErrorGrouper) FindGroup(errorMsg string) *ErrorGroup
func (*ErrorGrouper) FormatGroups ¶
func (eg *ErrorGrouper) FormatGroups() string
func (*ErrorGrouper) GetActive ¶
func (eg *ErrorGrouper) GetActive() []*ErrorGroup
func (*ErrorGrouper) GetResolution ¶
func (eg *ErrorGrouper) GetResolution(errorMsg string) string
func (*ErrorGrouper) IsKnown ¶
func (eg *ErrorGrouper) IsKnown(errorMsg string) bool
func (*ErrorGrouper) MarkResolved ¶
func (eg *ErrorGrouper) MarkResolved(groupID, resolution string)
func (*ErrorGrouper) Prune ¶
func (eg *ErrorGrouper) Prune(maxAge time.Duration)
type ErrorInstance ¶
type ErrorLearner ¶
type ErrorLearner struct {
Patterns map[string]*LearnedPattern
// contains filtered or unexported fields
}
func NewErrorLearner ¶
func NewErrorLearner() *ErrorLearner
func (*ErrorLearner) BuildFixSuggestion ¶
func (el *ErrorLearner) BuildFixSuggestion(errorMsg string) string
func (*ErrorLearner) Export ¶
func (el *ErrorLearner) Export() ([]byte, error)
func (*ErrorLearner) Import ¶
func (el *ErrorLearner) Import(data []byte) error
func (*ErrorLearner) Learn ¶
func (el *ErrorLearner) Learn(errorMsg, fix, language, category string)
func (*ErrorLearner) MatchLearned ¶
func (el *ErrorLearner) MatchLearned(errorMsg string) []*LearnedPattern
func (*ErrorLearner) PruneWeak ¶
func (el *ErrorLearner) PruneWeak(minConfidence float64)
func (*ErrorLearner) RecordFailure ¶
func (el *ErrorLearner) RecordFailure(patternID string)
func (*ErrorLearner) RecordSuccess ¶
func (el *ErrorLearner) RecordSuccess(patternID string)
func (*ErrorLearner) Stats ¶
func (el *ErrorLearner) Stats() ErrorLearnerStats
type ErrorLearnerStats ¶
type ErrorPattern ¶
type ErrorPatternDB ¶
type ErrorPatternDB struct {
// contains filtered or unexported fields
}
func NewErrorPatternDB ¶
func NewErrorPatternDB() *ErrorPatternDB
func (*ErrorPatternDB) FormatHints ¶
func (db *ErrorPatternDB) FormatHints(errorMsg string) string
func (*ErrorPatternDB) Match ¶
func (db *ErrorPatternDB) Match(errorMsg string) []ErrorPattern
func (*ErrorPatternDB) Record ¶
func (db *ErrorPatternDB) Record(trigger, rootCause, resolution string)
type ErrorRecovery ¶
type ErrorRecovery struct {
Strategies map[string]*RecoveryStrategy
History []RecoveryAttempt
MaxAttempts int
// contains filtered or unexported fields
}
func NewErrorRecovery ¶
func NewErrorRecovery() *ErrorRecovery
func (*ErrorRecovery) BuildRecoveryPrompt ¶
func (er *ErrorRecovery) BuildRecoveryPrompt(result *RecoveryResult) string
func (*ErrorRecovery) FormatHistory ¶
func (er *ErrorRecovery) FormatHistory(limit int) string
func (*ErrorRecovery) Recover ¶
func (er *ErrorRecovery) Recover(err error, ctx *RecoveryContext) (*RecoveryResult, error)
func (*ErrorRecovery) RegisterStrategy ¶
func (er *ErrorRecovery) RegisterStrategy(strategy *RecoveryStrategy)
func (*ErrorRecovery) ShouldRetry ¶
func (er *ErrorRecovery) ShouldRetry(err error) bool
func (*ErrorRecovery) SuccessRate ¶
func (er *ErrorRecovery) SuccessRate() float64
type LearnedPattern ¶
type LearnedPattern struct {
ID string `json:"id"`
Category string `json:"category"`
Language string `json:"language"`
Pattern string `json:"pattern"`
Example string `json:"example"`
Fix string `json:"fix"`
FixTemplate string `json:"fix_template"`
Confidence float64 `json:"confidence"`
SuccessCount int `json:"success_count"`
FailureCount int `json:"failure_count"`
LastSeen time.Time `json:"last_seen"`
}
type RecoveryAttempt ¶
type RecoveryContext ¶
type RecoveryResult ¶
type RecoveryStrategy ¶
type RecoveryStrategy struct {
Name string
ErrorPattern *regexp.Regexp
RecoverFn func(err error, context *RecoveryContext) (*RecoveryResult, error)
Priority int
SuccessCount int
FailureCount int
}
Click to show internal directories.
Click to hide internal directories.