diff --git a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts index cc587b5770e28..5548b8eefb94a 100644 --- a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts @@ -957,7 +957,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi }; const stopWatch = new StopWatch(); - let context: IRequestContext | undefined, error: ExtensionGalleryError | undefined, total: number = 0; + let context: IRequestContext | undefined, errorCode: ExtensionGalleryErrorCode | undefined, total: number = 0; try { context = await this.requestService.request({ @@ -989,9 +989,14 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi return { galleryExtensions: [], total }; } catch (e) { - const errorCode = isCancellationError(e) ? ExtensionGalleryErrorCode.Cancelled : getErrorMessage(e).startsWith('XHR timeout') ? ExtensionGalleryErrorCode.Timeout : ExtensionGalleryErrorCode.Failed; - error = new ExtensionGalleryError(getErrorMessage(e), errorCode); - throw error; + if (isCancellationError(e)) { + errorCode = ExtensionGalleryErrorCode.Cancelled; + throw e; + } else { + const errorMessage = getErrorMessage(e); + errorCode = errorMessage.startsWith('XHR timeout') ? ExtensionGalleryErrorCode.Timeout : ExtensionGalleryErrorCode.Failed; + throw new ExtensionGalleryError(errorMessage, errorCode); + } } finally { this.telemetryService.publicLog2('galleryService:query', { ...query.telemetryData, @@ -1000,7 +1005,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi success: !!context && isSuccess(context), responseBodySize: context?.res.headers['Content-Length'], statusCode: context ? String(context.res.statusCode) : undefined, - errorCode: error?.code, + errorCode, count: String(total) }); }