GithubHelp home page GithubHelp logo

morikuni / failure Goto Github PK

View Code? Open in Web Editor NEW
356.0 6.0 3.0 201 KB

failure is a utility package for handling application errors.

License: MIT License

Makefile 0.57% Go 99.43%
go golang error error-handling

failure's Issues

feature request: wrapping multiple errors

This is a feature request for wrapping multiple errors.

go 1.20 supports wrapping multiple errors.
https://tip.golang.org/doc/go1.20#errors

But, failure is a lack of support for wrapping multiple errors.

I want support for wrapping multiple errors.

But, I found you are working on v2.
Would you happen to have any plan for support for wrapping multiple errors on v2?

workaround and expected

I wrote current workaround and expected codes below.

err := doSomething(id)
if err != nil {
  // Currently, we have to combine `failure.Wrap and fmt.Errorf`
  return failure.Wrap(fmt.Errorf("foo bar :%w :%w", err, &MyError{
    ID: id
  }))

  // expected like this
  return failure.Wrap(err, failure.Message("foo bar"), failure.WithCause(&MyError{
    ID: id
  }))
}

Support structured log

Want to output errors in JSON format.

Plan:

  1. Add format sub package
  2. Add getter interfaces into that package
	type callStacker interface {
		GetCallStack() CallStack
	}
	type contexter interface {
		GetContext() Context
	}
	type messenger interface {
		GetMessage() string
	}
	type coder interface {
		GetCode() Code
	}
	type formatter interface {
		IsFormatter()
	}
  1. Support formatting using these interfaces

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.