Skip to content

Commit

Permalink
thanks, Joel
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell committed Nov 1, 2022
1 parent 9897f9b commit ccd9d3b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions sdk/azcore/runtime/policy_bearer_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package runtime

import (
"errors"
"net/http"
"time"

Expand Down Expand Up @@ -98,27 +99,18 @@ func (b *BearerTokenPolicy) Do(req *policy.Request) (*http.Response, error) {
}

func ensureNonRetriable(err error) error {
if err != nil {
if _, ok := err.(errorinfo.NonRetriable); !ok {
err = btpError{err}
}
var nre errorinfo.NonRetriable
if err != nil && !errors.As(err, &nre) {
err = btpError{err}
}
return err
}

// btpError is a wrapper that ensures RetryPolicy doesn't retry requests BearerTokenPolicy couldn't authorize
type btpError struct {
err error
}

func (n btpError) Error() string {
return n.err.Error()
error
}

func (btpError) NonRetriable() {}

func (n *btpError) Unwrap() error {
return n.err
}

var _ errorinfo.NonRetriable = (*btpError)(nil)

0 comments on commit ccd9d3b

Please sign in to comment.