Giter Club home page Giter Club logo

stackerr's Introduction

StackErr

Make your errors beautiful, because writing them is boring enough.

  • Automatically wrap your errors with the package and calling function name.
  • Keep it simple, and just plainly wrap your errors with Handle(err, "myFunction", "some", "args").
  • Full control over what is/isn't included in your errors. Include as much detail as you need to help with debugging.
  • Performant. StackErr is only invoked when handling errors.
  • Fully interoperable with other error handlers.

Installation

go get github.com/ovotech/stackerr

Usage

package main

import (
	"log"
	"strconv"

	"github.com/ovotech/stackerr"
)

func myFunction(input string) error {
	if _, err := strconv.Atoi(input); err != nil {
		return stackerr.Handle(err, "atoi", input, "some", "added", "details")
	}

	return nil
}

func main() {
	if err := myFunction("foo"); err != nil {
		log.Panic(err)
	}

	// panic: main.myFunction.atoi("foo", "some", "added", "details"): strconv.Atoi: parsing "foo": invalid syntax
}

Use with wrapcheck

If you use golangci-lint and the wrapcheck linter, you should add this package to your config to prevent errors:

linters-settings:
  wrapcheck:
    ignorePackageGlobs:
      - github.com/ovotech/stackerr

stackerr's People

Contributors

mike-gregory-ovo avatar dependabot[bot] avatar jlucktay avatar

Watchers

Dave Budd avatar Kat avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.