aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-30 14:00:34 +0100
committerLibravatar Rutger Broekhoff2023-12-30 14:00:34 +0100
commitf6c92c5e2d87ab1334648b0d1293771de7aae4a5 (patch)
tree265c3a06accd398a1e0a173af56d7392a5f94a24 /vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go
parent4f167c0fa991aa9ddb3f0252e23694b3aa6532b1 (diff)
downloadgitolfs3-f6c92c5e2d87ab1334648b0d1293771de7aae4a5.tar.gz
gitolfs3-f6c92c5e2d87ab1334648b0d1293771de7aae4a5.zip
Implement git-lfs-authenticate
Diffstat (limited to 'vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go')
-rw-r--r--vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go b/vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go
new file mode 100644
index 0000000..a893d35
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go
@@ -0,0 +1,47 @@
1//go:build go1.20
2// +build go1.20
3
4package jwt
5
6import (
7 "fmt"
8)
9
10// Unwrap implements the multiple error unwrapping for this error type, which is
11// possible in Go 1.20.
12func (je joinedError) Unwrap() []error {
13 return je.errs
14}
15
16// newError creates a new error message with a detailed error message. The
17// message will be prefixed with the contents of the supplied error type.
18// Additionally, more errors, that provide more context can be supplied which
19// will be appended to the message. This makes use of Go 1.20's possibility to
20// include more than one %w formatting directive in [fmt.Errorf].
21//
22// For example,
23//
24// newError("no keyfunc was provided", ErrTokenUnverifiable)
25//
26// will produce the error string
27//
28// "token is unverifiable: no keyfunc was provided"
29func newError(message string, err error, more ...error) error {
30 var format string
31 var args []any
32 if message != "" {
33 format = "%w: %s"
34 args = []any{err, message}
35 } else {
36 format = "%w"
37 args = []any{err}
38 }
39
40 for _, e := range more {
41 format += ": %w"
42 args = append(args, e)
43 }
44
45 err = fmt.Errorf(format, args...)
46 return err
47}