mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 16:58:55 -05:00
fixes #11779
This commit is contained in:
@@ -168,4 +168,20 @@ export function create(message: string, options: IErrorOptions = {}): Error {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getErrorMessage(err: any): string {
|
||||
if (!err) {
|
||||
return 'Error';
|
||||
}
|
||||
|
||||
if (err.message) {
|
||||
return err.message;
|
||||
}
|
||||
|
||||
if (err.stack) {
|
||||
return err.stack.split('\n')[0];
|
||||
}
|
||||
|
||||
return String(err);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { tmpdir } from 'os';
|
||||
import * as path from 'path';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { distinct } from 'vs/base/common/arrays';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { ArraySet } from 'vs/base/common/set';
|
||||
import { IGalleryExtension, IExtensionGalleryService, IQueryOptions, SortBy, SortOrder, IExtensionManifest } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionTelemetry';
|
||||
@@ -489,12 +490,18 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
|
||||
parsedUrl.query['redirect'] = 'true';
|
||||
|
||||
const cdnUrl = url.format(parsedUrl);
|
||||
const cdnOptions = assign({}, options, { url: cdnUrl });
|
||||
|
||||
return this.requestService.request(assign({}, options, { url: cdnUrl }))
|
||||
return this.requestService.request(cdnOptions)
|
||||
.then(context => context.res.statusCode === 200 ? context : TPromise.wrapError('expected 200'))
|
||||
.then(null, () => {
|
||||
.then(null, err => {
|
||||
this.telemetryService.publicLog('galleryService:requestError', { cdn: true, message: getErrorMessage(err) });
|
||||
this.telemetryService.publicLog('galleryService:cdnFallback', { url: cdnUrl });
|
||||
return this.requestService.request(options);
|
||||
|
||||
return this.requestService.request(options).then(null, err => {
|
||||
this.telemetryService.publicLog('galleryService:requestError', { cdn: false, message: getErrorMessage(err) });
|
||||
return TPromise.wrapError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user