Skip to content

Commit

Permalink
get the type / var name correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Maki committed Oct 24, 2024
1 parent 09fa80f commit 73548e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
56 changes: 28 additions & 28 deletions jws/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,99 +4,99 @@ import (
"fmt"
)

type errSign struct {
type signError struct {
error
}

var emptySignErr = errSign{fmt.Errorf(`jws.Sign: unknown error`)}
var errDefaultSignError = signerr(`unknown error`)

// SignError returns an error that can be passed to `errors.Is` to check if the error is a sign error.
func SignError() error {
return emptySignErr
return errDefaultSignError
}

func (e errSign) Unwrap() error {
func (e signError) Unwrap() error {
return e.error
}

func (errSign) Is(err error) bool {
_, ok := err.(errSign)
func (signError) Is(err error) bool {
_, ok := err.(signError)
return ok
}

func signerr(f string, args ...any) error {
return errSign{fmt.Errorf(`jws.Sign: `+f, args...)}
return signError{fmt.Errorf(`jws.Sign: `+f, args...)}
}

// This error is returned when jws.Verify fails, but note that there's another type of
// message that can be returned by jws.Verify, which is `errVerification`.
type errVerify struct {
type verifyError struct {
error
}

var emptyVerifyErr = errVerify{fmt.Errorf(`jws.Verify: unknown error`)}
var errDefaultVerifyError = verifyerr(`unknown error`)

// VerifyError returns an error that can be passed to `errors.Is` to check if the error is a verify error.
func VerifyError() error {
return emptyVerifyErr
return errDefaultVerifyError
}

func (e errVerify) Unwrap() error {
func (e verifyError) Unwrap() error {
return e.error
}

func (errVerify) Is(err error) bool {
_, ok := err.(errVerify)
func (verifyError) Is(err error) bool {
_, ok := err.(verifyError)
return ok
}

func verifyerr(f string, args ...any) error {
return errVerify{fmt.Errorf(`jws.Verify: `+f, args...)}
return verifyError{fmt.Errorf(`jws.Verify: `+f, args...)}
}

// errVerification is returned when the actual _verification_ of the key/payload fails.
type errVerification struct {
// verificationError is returned when the actual _verification_ of the key/payload fails.
type verificationError struct {
error
}

var emptyVerificationErr = errVerification{fmt.Errorf(`jws.Verify: unknown error`)}
var errDefaultVerificationError = verificationError{fmt.Errorf(`unknown verification error`)}

// VerificationError returns an error that can be passed to `errors.Is` to check if the error is a verification error.
func VerificationError() error {
return emptyVerificationErr
return errDefaultVerificationError
}

func (e errVerification) Unwrap() error {
func (e verificationError) Unwrap() error {
return e.error
}

func (errVerification) Is(err error) bool {
_, ok := err.(errVerification)
func (verificationError) Is(err error) bool {
_, ok := err.(verificationError)
return ok
}

type errParse struct {
type parseError struct {
error
}

var emptyParseErr = errParse{fmt.Errorf(`jws.Parse: unknown error`)}
var errDefaultParseError = parseerr(`unknown error`)

// ParseError returns an error that can be passed to `errors.Is` to check if the error is a parse error.
func ParseError() error {
return emptyParseErr
return errDefaultParseError
}

func (e errParse) Unwrap() error {
func (e parseError) Unwrap() error {
return e.error
}

func (errParse) Is(err error) bool {
_, ok := err.(errParse)
func (parseError) Is(err error) bool {
_, ok := err.(parseError)
return ok
}

func bparseerr(prefix string, f string, args ...any) error {
return errParse{fmt.Errorf(prefix+": "+f, args...)}
return parseError{fmt.Errorf(prefix+": "+f, args...)}
}

func parseerr(f string, args ...any) error {
Expand Down
2 changes: 1 addition & 1 deletion jws/jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func Verify(buf []byte, options ...VerifyOption) ([]byte, error) {
}

if err := verifier.Verify(verifyBuf.Bytes(), sig.signature, key); err != nil {
errs = append(errs, errVerification{err})
errs = append(errs, verificationError{err})
continue
}

Expand Down

0 comments on commit 73548e4

Please sign in to comment.