Skip to content

Commit 59b6ba3

Browse files
isidornpierceboggan
authored andcommitted
introuce networkError as a new type for CAPI errors (#500)
* introuce networkError as a new type for CAPI errors Fixes microsoft/vscode-internalbacklog/issues/5687 * fix errors
1 parent 30edb9d commit 59b6ba3

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

src/extension/prompt/node/chatMLFetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,14 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
654654
// this.logger.exception(err, `Error on conversation request`);
655655
if (fetcher.isInternetDisconnectedError(err)) {
656656
return {
657-
type: ChatFetchResponseType.Failed,
657+
type: ChatFetchResponseType.NetworkError,
658658
reason: `It appears you're not connected to the internet, please check your network connection and try again.`,
659659
requestId: requestId,
660660
serverRequestId: undefined,
661661
};
662662
} else if (fetcher.isFetcherError(err)) {
663663
return {
664-
type: ChatFetchResponseType.Failed,
664+
type: ChatFetchResponseType.NetworkError,
665665
reason: fetcher.getUserMessageForFetcherError(err),
666666
requestId: requestId,
667667
serverRequestId: undefined,

src/extension/prompt/node/defaultIntentRequestHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ export class DefaultIntentRequestHandler {
457457
return chatResult;
458458
}
459459
case ChatFetchResponseType.BadRequest:
460+
case ChatFetchResponseType.NetworkError:
460461
case ChatFetchResponseType.Failed: {
461462
const errorDetails = getErrorDetailsFromChatFetchError(fetchResult, (await this._authenticationService.getCopilotToken()).copilotPlan);
462463
const chatResult = { errorDetails, metadata: metadataFragment };

src/extension/xtab/node/xtabProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ export class XtabProvider extends ChainedStatelessNextEditProvider {
809809
case ChatFetchResponseType.BadRequest:
810810
case ChatFetchResponseType.NotFound:
811811
case ChatFetchResponseType.Failed:
812+
case ChatFetchResponseType.NetworkError:
812813
case ChatFetchResponseType.Unknown:
813814
return new NoNextEditReason.FetchFailure(errors.fromUnknown(fetchError));
814815
}

src/platform/chat/common/commonTypes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export enum ChatFetchResponseType {
9797
NotFound = 'notFound',
9898
Failed = 'failed',
9999
Unknown = 'unknown',
100+
NetworkError = 'networkError',
100101
AgentUnauthorized = 'agent_unauthorized',
101102
AgentFailedDependency = 'agent_failed_dependency',
102103
InvalidStatefulMarker = 'invalid_stateful_marker',
@@ -156,6 +157,10 @@ export type ChatFetchError =
156157
* unexpected went wrong.
157158
*/
158159
| { type: ChatFetchResponseType.Failed; reason: string; requestId: string; serverRequestId: string | undefined; streamError?: APIErrorResponse }
160+
/**
161+
* We requested conversation, but didn't come up with any results because of a network error
162+
*/
163+
| { type: ChatFetchResponseType.NetworkError; reason: string; requestId: string; serverRequestId: string | undefined; streamError?: APIErrorResponse }
159164
/**
160165
* We requested conversation, but didn't come up with any results for some "unknown"
161166
* reason, such as slur redaction or snippy.
@@ -274,6 +279,8 @@ export function getErrorDetailsFromChatFetchError(fetchResult: ChatFetchError, c
274279
case ChatFetchResponseType.BadRequest:
275280
case ChatFetchResponseType.Failed:
276281
return { message: l10n.t(`Sorry, your request failed. Please try again. Request id: {0}\n\nReason: {1}`, fetchResult.requestId, fetchResult.reason) };
282+
case ChatFetchResponseType.NetworkError:
283+
return { message: l10n.t(`Sorry, there was a network error. Please try again later. Request id: {0}\n\nReason: {1}`, fetchResult.requestId, fetchResult.reason) };
277284
case ChatFetchResponseType.Filtered:
278285
case ChatFetchResponseType.PromptFiltered:
279286
return {

0 commit comments

Comments
 (0)