提交 c0766762 编写于 作者: B Benjamin Pasero

fix #63897

上级 55cbf197
......@@ -201,7 +201,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
try {
storedWorkspace = this.doParseStoredWorkspace(workspace.configPath, rawWorkspaceContents);
} catch (error) {
return TPromise.wrapError(error);
return Promise.reject(error);
}
const sourceConfigFolder = dirname(workspace.configPath);
......
......@@ -191,7 +191,7 @@ export class EditorControl extends Disposable {
// Operation done
operation.stop();
return TPromise.wrapError(e);
return Promise.reject(e);
});
}
......
......@@ -264,7 +264,7 @@ export class ConfigurationEditingService {
this.editorService.openEditor({ resource });
}
private wrapError<T = never>(code: ConfigurationEditingErrorCode, target: ConfigurationTarget, operation: IConfigurationEditOperation): Promise<T> {
private reject<T = never>(code: ConfigurationEditingErrorCode, target: ConfigurationTarget, operation: IConfigurationEditOperation): Promise<T> {
const message = this.toErrorMessage(code, target, operation);
return Promise.reject(new ConfigurationEditingError(message, code));
......@@ -377,45 +377,45 @@ export class ConfigurationEditingService {
if (!operation.workspaceStandAloneConfigurationKey) {
const validKeys = this.configurationService.keys().default;
if (validKeys.indexOf(operation.key) < 0 && !OVERRIDE_PROPERTY_PATTERN.test(operation.key)) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_UNKNOWN_KEY, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_UNKNOWN_KEY, target, operation);
}
}
if (operation.workspaceStandAloneConfigurationKey) {
// Global tasks and launches are not supported
if (target === ConfigurationTarget.USER) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_INVALID_USER_TARGET, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_USER_TARGET, target, operation);
}
// Workspace tasks are not supported
if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY && this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && operation.target === ConfigurationTarget.WORKSPACE) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_TARGET, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_TARGET, target, operation);
}
}
// Target cannot be workspace or folder if no workspace opened
if ((target === ConfigurationTarget.WORKSPACE || target === ConfigurationTarget.WORKSPACE_FOLDER) && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_NO_WORKSPACE_OPENED, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_NO_WORKSPACE_OPENED, target, operation);
}
if (target === ConfigurationTarget.WORKSPACE) {
if (!operation.workspaceStandAloneConfigurationKey) {
const configurationProperties = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).getConfigurationProperties();
if (configurationProperties[operation.key].scope === ConfigurationScope.APPLICATION) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION, target, operation);
}
}
}
if (target === ConfigurationTarget.WORKSPACE_FOLDER) {
if (!operation.resource) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_TARGET, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_TARGET, target, operation);
}
if (!operation.workspaceStandAloneConfigurationKey) {
const configurationProperties = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).getConfigurationProperties();
if (configurationProperties[operation.key].scope !== ConfigurationScope.RESOURCE) {
return this.wrapError(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_CONFIGURATION, target, operation);
return this.reject(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_CONFIGURATION, target, operation);
}
}
}
......@@ -425,12 +425,12 @@ export class ConfigurationEditingService {
const model = reference.object.textEditorModel;
if (this.hasParseErrors(model, operation)) {
return this.wrapError<typeof reference>(ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION, target, operation);
return this.reject<typeof reference>(ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION, target, operation);
}
// Target cannot be dirty if not writing into buffer
if (checkDirty && this.textFileService.isDirty(operation.resource)) {
return this.wrapError<typeof reference>(ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY, target, operation);
return this.reject<typeof reference>(ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY, target, operation);
}
return reference;
});
......
......@@ -103,18 +103,18 @@ export class JSONEditingService implements IJSONEditingService {
const model = reference.object.textEditorModel;
if (this.hasParseErrors(model)) {
return this.wrapError<IReference<ITextEditorModel>>(JSONEditingErrorCode.ERROR_INVALID_FILE);
return this.reject<IReference<ITextEditorModel>>(JSONEditingErrorCode.ERROR_INVALID_FILE);
}
// Target cannot be dirty if not writing into buffer
if (checkDirty && this.textFileService.isDirty(resource)) {
return this.wrapError<IReference<ITextEditorModel>>(JSONEditingErrorCode.ERROR_FILE_DIRTY);
return this.reject<IReference<ITextEditorModel>>(JSONEditingErrorCode.ERROR_FILE_DIRTY);
}
return reference;
});
}
private wrapError<T>(code: JSONEditingErrorCode): Promise<T> {
private reject<T>(code: JSONEditingErrorCode): Promise<T> {
const message = this.toErrorMessage(code);
return Promise.reject(new JSONEditingError(message, code));
}
......
......@@ -232,7 +232,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
// Set flags back to previous values, we are still dirty if revert failed
undo();
return TPromise.wrapError(error);
return Promise.reject(error);
});
}
......@@ -344,7 +344,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
// Otherwise bubble up the error
return TPromise.wrapError<TextFileEditorModel>(error);
return Promise.reject<TextFileEditorModel>(error);
});
}
......@@ -467,7 +467,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}, error => {
this.createTextEditorModelPromise = null;
return TPromise.wrapError<TextFileEditorModel>(error);
return Promise.reject<TextFileEditorModel>(error);
});
});
......
......@@ -214,7 +214,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
// Remove from pending loads
this.mapResourceToPendingModelLoaders.delete(resource);
return TPromise.wrapError<ITextFileEditorModel>(error);
return Promise.reject<ITextFileEditorModel>(error);
});
}
......
......@@ -623,7 +623,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
return this.fileService.del(target).then(() => this.doSaveTextFileAs(sourceModel, resource, target, options));
}
return TPromise.wrapError(error);
return Promise.reject(error);
});
}
......@@ -687,7 +687,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
// Otherwise bubble up the error
else {
return TPromise.wrapError(error);
return Promise.reject(error);
}
return void 0;
......@@ -791,7 +791,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
// In case of an error, discard any dirty target backups that were made
return TPromise.join(dirtyTargetModels.map(dirtyTargetModel => this.backupFileService.discardResourceBackup(dirtyTargetModel)))
.then(() => TPromise.wrapError(error));
.then(() => Promise.reject(error));
});
});
});
......
......@@ -320,7 +320,7 @@ suite('Files - TextFileEditorModel', () => {
TextFileEditorModel.setSaveParticipant({
participate: (model) => {
return TPromise.wrapError(new Error('boom'));
return Promise.reject(new Error('boom'));
}
});
......
......@@ -210,7 +210,7 @@ export class TestTextFileService extends TextFileService {
const error = this.resolveTextContentError;
this.resolveTextContentError = null;
return TPromise.wrapError<IRawTextContent>(error);
return Promise.reject(error);
}
return this.fileService.resolveContent(resource, options).then((content): IRawTextContent => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册