scope_error

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package scope_error defines a scoped error.

Sometimes you need a scoped error, which can help to group multiple errors for later simple check via errors.Is().

Example:

var ErrRepoError = scope_error.New("repo error")

// some sql method returns error
rErr := repo.GetOrder(id)

// you just wrap it at return...
return ErrRepoError.WithCause(rErr)

// later check
if errors.Is(err, ErrRepoError) {
    // any error wrapped via WithCause will ends here
    log.Println("ERROR", err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScopeError

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

func New

func New(scope string) *ScopeError

func (ScopeError) Error

func (s ScopeError) Error() string

func (*ScopeError) Is

func (s *ScopeError) Is(err error) bool

func (*ScopeError) Unwrap

func (s *ScopeError) Unwrap() error

func (*ScopeError) WithCause

func (s *ScopeError) WithCause(err error) error

WithCause returns a new scope error clone with cause set.

Note: Is() will returns true for clone and original.

Jump to

Keyboard shortcuts

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