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.
Click to show internal directories.
Click to hide internal directories.