errorconfig

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package errorconfig defines types for structured error handling configuration.

Index

Constants

This section is empty.

Variables

View Source
var ErrorCleanPattern = regexp.MustCompile(`[^a-zA-Z0-9./'"():=\- ]+`)

ErrorCleanPattern is used to clean error messages when looking for retry and ignore patterns.

Functions

func ExtractErrorMessage

func ExtractErrorMessage(err error) string

ExtractErrorMessage extracts and cleans the error message for pattern matching.

func MatchesAnyRegexpPattern

func MatchesAnyRegexpPattern(input string, patterns []*Pattern) bool

MatchesAnyRegexpPattern checks if the input string matches any of the provided compiled patterns.

Types

type Action

type Action struct {
	IgnoreSignals   map[string]any
	IgnoreBlockName string
	RetryBlockName  string
	IgnoreMessage   string
	RetryAttempts   int
	RetrySleepSecs  int
	ShouldIgnore    bool
	ShouldRetry     bool
}

Action represents the action to take when an error occurs.

type Config

type Config struct {
	Retry  map[string]*RetryConfig
	Ignore map[string]*IgnoreConfig
}

Config is the extracted errors handling configuration.

func (*Config) AttemptErrorRecovery

func (c *Config) AttemptErrorRecovery(l log.Logger, err error, currentAttempt int) (*Action, error)

AttemptErrorRecovery attempts to recover from an error by checking the ignore and retry rules.

type IgnoreConfig

type IgnoreConfig struct {
	Signals         map[string]any
	Name            string
	Message         string
	IgnorableErrors []*Pattern
}

IgnoreConfig represents the configuration for ignoring specific errors.

type MaxAttemptsReachedError

type MaxAttemptsReachedError struct {
	Err        error
	MaxRetries int
}

MaxAttemptsReachedError is returned when the maximum number of retry attempts is reached.

func (*MaxAttemptsReachedError) Error

func (e *MaxAttemptsReachedError) Error() string

type Pattern

type Pattern struct {
	Pattern  *regexp.Regexp `clone:"shadowcopy"`
	Negative bool
}

Pattern represents a regex pattern for matching errors, with optional negation.

type RetryConfig

type RetryConfig struct {
	Name             string
	RetryableErrors  []*Pattern
	MaxAttempts      int
	SleepIntervalSec int
}

RetryConfig represents the configuration for retrying specific errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL