patherr

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 1 Imported by: 0

README

goverter/patherr

Build Status codecov Go Report Card Go Reference latest release

github.com/goverter/patherr provides an implementation for the goverter feature wrapErrorsUsing. You can use directly or as a template for creating your own implementation.

Use it by configuring wrapErrorsUsing on your conversion interface:

// goverter:converter
// goverter:wrapErrorsUsing github.com/goverter/patherr
type Converter interface {
	Convert(Input) (Output, error)
}

Report bugs and request features in the github.com/jmattheis/goverter repository.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(err error, subPath ...Element) error

Wrap wraps the error into a PathError or appends the path to an already existing PathError.

Types

type Element

type Element interface {
	String() string
	Prefix() string
}

func Key

func Key(key any) Element

type Field

type Field string

func (Field) Prefix

func (Field) Prefix() string

func (Field) String

func (field Field) String() string

type Index

type Index int

func (Index) Prefix

func (Index) Prefix() string

func (Index) String

func (i Index) String() string

type KeyElement

type KeyElement struct {
	// contains filtered or unexported fields
}

func (KeyElement) Prefix

func (KeyElement) Prefix() string

func (KeyElement) String

func (key KeyElement) String() string

type Path

type Path []Element

func (Path) String

func (p Path) String() string

type PathError

type PathError struct {
	Inner error
	Path  Path
}

PathError is an error with a path where the error occurred.

func (*PathError) Error

func (e *PathError) Error() string

func (*PathError) String

func (e *PathError) String() string

func (*PathError) Unwrap

func (e *PathError) Unwrap() error

Jump to

Keyboard shortcuts

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