summaryrefslogtreecommitdiff
path: root/vendor/github.com/golang-jwt/jwt/v5/errors.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-08-12 16:04:30 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-08-12 16:04:30 +0200
commit1edc0f7b3c9264c2d4b21455afb5fc2e14ff1ab7 (patch)
tree4f5525b6141f2744b95eedaec744873c36f799fd /vendor/github.com/golang-jwt/jwt/v5/errors.go
parent[feature] scheduled statuses (#4274) (diff)
downloadgotosocial-1edc0f7b3c9264c2d4b21455afb5fc2e14ff1ab7.tar.xz
[chore] bump to code.superseriousbusiness.org/oauth2/v4@ssb-v4.5.3-2 (#4367)
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4367 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/golang-jwt/jwt/v5/errors.go')
-rw-r--r--vendor/github.com/golang-jwt/jwt/v5/errors.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/golang-jwt/jwt/v5/errors.go b/vendor/github.com/golang-jwt/jwt/v5/errors.go
index 23bb616dd..14e007516 100644
--- a/vendor/github.com/golang-jwt/jwt/v5/errors.go
+++ b/vendor/github.com/golang-jwt/jwt/v5/errors.go
@@ -2,6 +2,7 @@ package jwt
import (
"errors"
+ "fmt"
"strings"
)
@@ -47,3 +48,42 @@ func joinErrors(errs ...error) error {
errs: errs,
}
}
+
+// Unwrap implements the multiple error unwrapping for this error type, which is
+// possible in Go 1.20.
+func (je joinedError) Unwrap() []error {
+ return je.errs
+}
+
+// newError creates a new error message with a detailed error message. The
+// message will be prefixed with the contents of the supplied error type.
+// Additionally, more errors, that provide more context can be supplied which
+// will be appended to the message. This makes use of Go 1.20's possibility to
+// include more than one %w formatting directive in [fmt.Errorf].
+//
+// For example,
+//
+// newError("no keyfunc was provided", ErrTokenUnverifiable)
+//
+// will produce the error string
+//
+// "token is unverifiable: no keyfunc was provided"
+func newError(message string, err error, more ...error) error {
+ var format string
+ var args []any
+ if message != "" {
+ format = "%w: %s"
+ args = []any{err, message}
+ } else {
+ format = "%w"
+ args = []any{err}
+ }
+
+ for _, e := range more {
+ format += ": %w"
+ args = append(args, e)
+ }
+
+ err = fmt.Errorf(format, args...)
+ return err
+}