Skip to content

Commit bcacab1

Browse files
committed
add errors.Join(errs) convenience method
- bumped minimum Go version to 1.20
1 parent ff4a9c2 commit bcacab1

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Builds on Go 1.13 errors by adding HTTP statuses and GRPC codes to them.
1212

1313
## Prerequisites
1414

15-
Go 1.13
15+
Go 1.20 or later is required to use this package.
1616

1717
## Embeddable codes
1818

@@ -113,6 +113,8 @@ The functions `errors.TypeCode(error) string`, `errors.HTTPCode(error) int`, and
113113
be used to fetch specific code. They're more convenient to use than the interfaces directly. The catch is they have
114114
defined rules for the values they return.
115115

116+
The function `errors.Join(errs ...error) error`, made available in Go 1.20 has been added to this package as an additional convenience.
117+
116118
#### errors.TypeCode(error) string
117119

118120
If the error implements or has wrapped an error that implements `errors.TypeCoder` it will return the code from that

errors.go

+5
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ func Is(err, target error) bool {
172172
func Unwrap(err error) error {
173173
return stderrors.Unwrap(err)
174174
}
175+
176+
// Join implements the standard errors.Join for convenience
177+
func Join(errs ...error) error {
178+
return stderrors.Join(errs...)
179+
}

go.mod

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
module github.com/stackus/errors
22

3-
go 1.13
3+
go 1.20
44

55
require (
66
github.com/cucumber/godog v0.12.5
7-
google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8 // indirect
87
google.golang.org/grpc v1.47.0
98
google.golang.org/protobuf v1.28.0
109
)
10+
11+
require (
12+
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
13+
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
14+
github.com/gofrs/uuid v4.0.0+incompatible // indirect
15+
github.com/golang/protobuf v1.5.2 // indirect
16+
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
17+
github.com/hashicorp/go-memdb v1.3.0 // indirect
18+
github.com/hashicorp/golang-lru v0.5.4 // indirect
19+
github.com/spf13/pflag v1.0.5 // indirect
20+
google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8 // indirect
21+
)

go.sum

-3
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
154154
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
155155
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
156156
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
157-
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
158157
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
159158
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
160-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
161159
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
162160
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
163161
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -384,7 +382,6 @@ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
384382
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
385383
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
386384
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
387-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
388385
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
389386
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
390387
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

0 commit comments

Comments
 (0)