Skip to content

Commit

Permalink
Make error field of MalformedTokenError private.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyp committed Mar 15, 2024
1 parent 0867219 commit 1910815
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dynoid/dynoid.go
Expand Up @@ -32,15 +32,15 @@ func (e *UntrustedIssuerError) Error() string {

// Returned when the token doesn't match the expected format
type MalformedTokenError struct {
Err error
err error
}

func (e *MalformedTokenError) Error() string {
return fmt.Sprintf("malformed token: %s", e.Err.Error())
return fmt.Sprintf("malformed token: %s", e.err.Error())
}

func (e *MalformedTokenError) Unwrap() error {
return e.Err
return e.err
}

type staticError string
Expand Down Expand Up @@ -286,14 +286,14 @@ func parseIssuer(p string) (string, error) {
parts := strings.Split(p, ".")
if len(parts) != 3 {
return "", &MalformedTokenError{
Err: fmt.Errorf("expected 3 parts got %d", len(parts)),
err: fmt.Errorf("expected 3 parts got %d", len(parts)),
}
}

payload, err := base64.RawURLEncoding.DecodeString(parts[1])
if err != nil {
return "", &MalformedTokenError{
Err: fmt.Errorf("unable to decode token: %w", err),
err: fmt.Errorf("unable to decode token: %w", err),
}
}

Expand All @@ -304,7 +304,7 @@ func parseIssuer(p string) (string, error) {
err = json.Unmarshal(payload, &v)
if err != nil {
return "", &MalformedTokenError{
Err: fmt.Errorf("unable to unmarshal token: %w", err),
err: fmt.Errorf("unable to unmarshal token: %w", err),
}
}

Expand Down

0 comments on commit 1910815

Please sign in to comment.