No description
Find a file
2022-03-27 03:03:42 +02:00
try update to use generics 2022-03-27 03:03:42 +02:00
.drone.yml faster ci pipeline 2021-10-14 10:31:05 +02:00
.editorconfig Initial commit 2021-10-01 17:17:34 +02:00
.golangci.yaml Fix gofmt issue 2021-10-14 10:27:49 +02:00
.pre-commit-config.yaml Add pre-commit and drone CI 2021-10-14 08:07:33 +02:00
go.mod update to use generics 2022-03-27 03:03:42 +02:00
LICENSE Initial commit 2021-10-01 17:17:34 +02:00
README.md update to use generics 2022-03-27 03:03:42 +02:00

gotry

This package is a fork of lainio's err2 package.

Handle errors

Instead of the idiomatic go way of handling errors, which involves if-conditions for every possible error, ...

func myFunction() (err error) {
  b, err := ioutil.ReadAll(r)
  if err != nil {
    return err
  }
}

you can wrap the error-throwing function in a try wrapper.

func myFunction() (err error) {
  defer err2.Return(&err)

  b := try.Bytes(ioutil.ReadAll(r))

  return
}