From e414d01dc366573d4b5fe8611355b88aca47abb2 Mon Sep 17 00:00:00 2001 From: Vladyslav Zhukovskii Date: Fri, 9 Jun 2017 14:18:35 +0300 Subject: [PATCH] Provide error message to UI (#5302) --- .../che/ide/resources/impl/ResourceManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java index 221f6e7effd..eeef4f947ee 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/resources/impl/ResourceManager.java @@ -379,9 +379,9 @@ Promise createProject(final Project.ProjectRequest createRequest) { return findResource(path, true).thenPromise(resource -> { if (resource.isPresent()) { if (resource.get().isProject()) { - throw new IllegalStateException("Project already exists"); + return promises.reject(new IllegalStateException("Project already exists")); } else if (resource.get().isFile()) { - throw new IllegalStateException("File can not be converted to project"); + return promises.reject(new IllegalStateException("File can not be converted to project")); } return update(path, createRequest); @@ -393,7 +393,7 @@ Promise createProject(final Project.ProjectRequest createRequest) { final List configDtoList = asDto(projectConfigList); return ps.createBatchProjects(configDtoList).thenPromise( - configList -> ps.getProjects().then((Function, Project>)updatedConfiguration -> { + configList -> ps.getProjects().thenPromise(updatedConfiguration -> { //cache new configs cachedConfigs = updatedConfiguration.toArray(new ProjectConfigDto[updatedConfiguration.size()]); @@ -403,11 +403,11 @@ Promise createProject(final Project.ProjectRequest createRequest) { store.register(newResource); eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(newResource, ADDED | DERIVED))); - return newResource; + return promises.resolve(newResource); } } - throw new IllegalStateException("Created project is not found"); + return promises.reject(new IllegalStateException("Created project is not found")); })); }); }