errmapper

package
v3.25.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errmapper is a service that resolves a given error or error chain to a new single error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchType

type MatchType int

MatchType represents the type of matching operation to be performed on a given error chain. Can be either 'MatchAll' or 'MatchAny'.

const (
	MatchAll MatchType = iota
	MatchAny
)

type Rule

type Rule struct {
	// Targets is a list of errors to match against.
	Targets []error

	// MatchType is the type of matching operation to be performed on a given error chain.
	// Can be either MatchAll or MatchAny.
	MatchType MatchType

	// ResultFn is a function to build the result error.
	ResultFn func(err error) error
}

Rule holds information about a rule to be applied to a given error or error chain.

func NewRule

func NewRule(targets []error, matchType MatchType, result error) Rule

NewRule returns a new Rule instance,. The given result error is returned when the rule matches.

func NewRuleWithResultFunc added in v3.25.0

func NewRuleWithResultFunc(targets []error, matchType MatchType, fn func(err error) error) Rule

NewRuleWithResultFunc builds a Rule instance with a function to build the result error.

type Service

type Service interface {

	// Resolve resolves a given error or error chain to a new single error
	Resolve(err error) error
}

func New

func New(rules []Rule) Service

Jump to

Keyboard shortcuts

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