Skip to content

Commit

Permalink
Provide error message to UI (eclipse-che#5302)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Zhukovskii authored Jun 9, 2017
1 parent 1e9e912 commit e414d01
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ Promise<Project> 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);
Expand All @@ -393,7 +393,7 @@ Promise<Project> createProject(final Project.ProjectRequest createRequest) {
final List<NewProjectConfigDto> configDtoList = asDto(projectConfigList);

return ps.createBatchProjects(configDtoList).thenPromise(
configList -> ps.getProjects().then((Function<List<ProjectConfigDto>, Project>)updatedConfiguration -> {
configList -> ps.getProjects().thenPromise(updatedConfiguration -> {
//cache new configs
cachedConfigs = updatedConfiguration.toArray(new ProjectConfigDto[updatedConfiguration.size()]);

Expand All @@ -403,11 +403,11 @@ Promise<Project> 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"));
}));
});
}
Expand Down

0 comments on commit e414d01

Please sign in to comment.