提交 870c700e 编写于 作者: J Joao Moreno

parse gallery error message

fixes #6761
上级 91198c9b
...@@ -15,7 +15,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' ...@@ -15,7 +15,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { IEventService } from 'vs/platform/event/common/event'; import { IEventService } from 'vs/platform/event/common/event';
import { EventService } from 'vs/platform/event/common/eventService'; import { EventService } from 'vs/platform/event/common/eventService';
import { IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionManagementService, IExtensionGalleryService, IQueryResult } from 'vs/platform/extensionManagement/common/extensionManagement';
import { getExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil'; import { getExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService'; import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/extensionGalleryService';
...@@ -68,20 +68,31 @@ class Main { ...@@ -68,20 +68,31 @@ class Main {
return TPromise.wrapError(localize('alreadyInstalled', "Extension '{0}' is already installed.", id)); return TPromise.wrapError(localize('alreadyInstalled', "Extension '{0}' is already installed.", id));
} }
return this.extensionGalleryService.query({ ids: [id] }).then(result => { return this.extensionGalleryService.query({ ids: [id] })
const [extension] = result.firstPage; .then<IQueryResult>(null, err => {
if (err.responseText) {
if (!extension) { try {
return TPromise.wrapError(`${ notFound(id) }\n${ useId }`); const response = JSON.parse(err.responseText);
} return TPromise.wrapError(response.message);
} catch (e) {
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id)); return TPromise.wrapError(err);
console.log(localize('installing', "Installing...")); }
}
return this.extensionManagementService.install(extension).then(extension => { })
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version)); .then(result => {
const [extension] = result.firstPage;
if (!extension) {
return TPromise.wrapError(`${ notFound(id) }\n${ useId }`);
}
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
console.log(localize('installing', "Installing..."));
return this.extensionManagementService.install(extension).then(extension => {
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version));
});
}); });
});
})); }));
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册