Skip to content

Package errors provides error wrapping with stack trace and human-readable operations.

License

Notifications You must be signed in to change notification settings

w1ck3dg0ph3r/go-errors

Repository files navigation

go-errors Build Status Go Report Card codecov

Package errors provides error wrapping with stack trace and human-readable operations.

Features

  • Stacked human-readable operations associated with errors
  • Customizable error kinds and codes with checking
  • Error list aka multi-error
  • Error group to aggregate errors from goroutines in a list
  • Stack trace capture

Install

go get -u github.com/w1ck3dg0ph3r/go-errors

Usage

package mypackage

import "github.com/w1ck3dg0ph3r/go-errors"

func MyFunc() error {
    const op = errors.Op("mypackage.MyFunc")
    
    if err := DoSmth(); err != nil {
    	if errors.IsAnyOf(err, errors.Transient, errors.Deadlock) {
    		// TODO: retry
        }
        LogError(err.Error(), errors.Ops(err), errors.Trace(err))
    	return errors.E(op, "can't do smth", err)
    }
    
    return nil
}

Contributing

Any contributions are welcome in a form of issues and pull requests.

About

Package errors provides error wrapping with stack trace and human-readable operations.

Topics

Resources

License

Stars

Watchers

Forks

Languages