| | | 1 | | namespace NexusLabs.Needlr.Copilot; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Thrown when a Copilot request fails because the caller is not |
| | | 5 | | /// authenticated. This covers two distinct cases: |
| | | 6 | | /// </summary> |
| | | 7 | | /// <remarks> |
| | | 8 | | /// <para> |
| | | 9 | | /// 1. <b>No token configured locally.</b> |
| | | 10 | | /// <see cref="GitHubOAuthTokenProvider"/> could not resolve a GitHub OAuth |
| | | 11 | | /// token from any configured source (explicit option, apps.json, or |
| | | 12 | | /// environment variables). The HTTP request is never sent. |
| | | 13 | | /// </para> |
| | | 14 | | /// <para> |
| | | 15 | | /// 2. <b>Token rejected by the server.</b> |
| | | 16 | | /// <see cref="CopilotMcpToolClient"/> received an HTTP <c>401 Unauthorized</c> |
| | | 17 | | /// or <c>403 Forbidden</c> response from the Copilot MCP endpoint, indicating |
| | | 18 | | /// the supplied token is invalid, expired, or lacks the required scopes. |
| | | 19 | | /// </para> |
| | | 20 | | /// <para> |
| | | 21 | | /// Callers should catch this exception to implement fallback behavior such |
| | | 22 | | /// as switching to an alternative search provider or surfacing a |
| | | 23 | | /// re-authentication prompt to the user. This is the auth analog of |
| | | 24 | | /// <see cref="CopilotRateLimitException"/> and exists so consumers do not |
| | | 25 | | /// have to string-match free-text error messages from the upstream server. |
| | | 26 | | /// </para> |
| | | 27 | | /// </remarks> |
| | | 28 | | public sealed class CopilotAuthException : Exception |
| | | 29 | | { |
| | | 30 | | /// <summary> |
| | | 31 | | /// Creates a new <see cref="CopilotAuthException"/> with the given |
| | | 32 | | /// human-readable message. |
| | | 33 | | /// </summary> |
| | | 34 | | /// <param name="message">A description of the auth failure.</param> |
| | | 35 | | public CopilotAuthException(string message) |
| | 5 | 36 | | : base(message) |
| | | 37 | | { |
| | 5 | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Creates a new <see cref="CopilotAuthException"/> wrapping the given |
| | | 42 | | /// inner exception. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <param name="message">A description of the auth failure.</param> |
| | | 45 | | /// <param name="innerException">The underlying exception that caused this failure.</param> |
| | | 46 | | public CopilotAuthException(string message, Exception innerException) |
| | 0 | 47 | | : base(message, innerException) |
| | | 48 | | { |
| | 0 | 49 | | } |
| | | 50 | | } |