Skip to content

Commit

Permalink
Merge pull request #2632 from mtrmac/stubs-broken
Browse files Browse the repository at this point in the history
Move JSONFormatToInvalidSignatureError to an unconditionally-included file
  • Loading branch information
rhatdan authored Jan 7, 2025
2 parents 0d450be + 3cca76b commit 43c2a74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions signature/internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ func (err InvalidSignatureError) Error() string {
func NewInvalidSignatureError(msg string) InvalidSignatureError {
return InvalidSignatureError{msg: msg}
}

// JSONFormatToInvalidSignatureError converts JSONFormatError to InvalidSignatureError.
// All other errors are returned as is.
func JSONFormatToInvalidSignatureError(err error) error {
if formatErr, ok := err.(JSONFormatError); ok {
err = NewInvalidSignatureError(formatErr.Error())
}
return err
}
9 changes: 0 additions & 9 deletions signature/internal/rekor_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ type UntrustedRekorPayload struct {
// A compile-time check that UntrustedRekorSET implements json.Unmarshaler
var _ json.Unmarshaler = (*UntrustedRekorSET)(nil)

// JSONFormatToInvalidSignatureError converts JSONFormatError to InvalidSignatureError.
// All other errors are returned as is.
func JSONFormatToInvalidSignatureError(err error) error {
if formatErr, ok := err.(JSONFormatError); ok {
err = NewInvalidSignatureError(formatErr.Error())
}
return err
}

// UnmarshalJSON implements the json.Unmarshaler interface
func (s *UntrustedRekorSET) UnmarshalJSON(data []byte) error {
return JSONFormatToInvalidSignatureError(s.strictUnmarshalJSON(data))
Expand Down

0 comments on commit 43c2a74

Please sign in to comment.