refactor(copilot): improve code quality in authentication module

- Add Unwrap() to AuthenticationError for proper error chain handling with errors.Is/As
- Extract hardcoded header values to constants for maintainability
- Replace verbose status code checks with isHTTPSuccess() helper
- Remove unused ExtractBearerToken() and BuildModelsURL() functions
- Make buildChatCompletionURL() private (only used internally)
- Remove unused 'strings' import
This commit is contained in:
Ernesto Martínez
2025-11-28 08:32:36 +01:00
parent efd28bf981
commit 2c296e9cb1
3 changed files with 28 additions and 28 deletions

View File

@@ -55,6 +55,11 @@ func (e *AuthenticationError) Error() string {
return fmt.Sprintf("%s: %s", e.Type, e.Message)
}
// Unwrap returns the underlying cause of the error.
func (e *AuthenticationError) Unwrap() error {
return e.Cause
}
// Common authentication error types for GitHub Copilot device flow.
var (
// ErrDeviceCodeFailed represents an error when requesting the device code fails.