refactor(copilot): address PR review feedback

- Simplify error type checking in oauth.go using errors.As directly
- Remove redundant errors.As call in GetUserFriendlyMessage
- Remove unused CachedAPIToken and TokenManager types (dead code)
This commit is contained in:
Ernesto Martínez
2025-11-27 22:47:51 +01:00
parent 3a9ac7ef33
commit efd28bf981
3 changed files with 10 additions and 86 deletions
+2 -6
View File
@@ -3,6 +3,7 @@ package copilot
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -118,12 +119,7 @@ func (c *DeviceFlowClient) PollForToken(ctx context.Context, deviceCode *DeviceC
token, err := c.exchangeDeviceCode(ctx, deviceCode.DeviceCode)
if err != nil {
var authErr *AuthenticationError
if IsAuthenticationError(err) {
if ok := (err.(*AuthenticationError)); ok != nil {
authErr = ok
}
}
if authErr != nil {
if errors.As(err, &authErr) {
switch authErr.Type {
case ErrAuthorizationPending.Type:
// Continue polling