Skip to content

Commit

Permalink
CHE-2017: skip loading project's commands with not valid JSON (#4755)
Browse files Browse the repository at this point in the history
  • Loading branch information
azatsarynnyy committed Apr 11, 2017
1 parent a04a7ed commit c1ca147
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.che.ide.command.manager;

import com.google.gwt.json.client.JSONException;
import com.google.inject.Inject;
import com.google.inject.Singleton;

Expand All @@ -23,6 +24,7 @@
import org.eclipse.che.ide.api.project.MutableProjectConfig;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.dto.DtoFactory;
import org.eclipse.che.ide.util.loging.Log;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -53,8 +55,13 @@ List<CommandImpl> getCommands(Project project) {

Map<String, CommandImpl> commands = new HashMap<>(attrValues.size());
for (String commandJson : attrValues) {
CommandDto command = dtoFactory.createDtoFromJson(commandJson, CommandDto.class);
commands.put(command.getName(), new CommandImpl(command));
try {
CommandDto commandDto = dtoFactory.createDtoFromJson(commandJson, CommandDto.class);
commands.put(commandDto.getName(), new CommandImpl(commandDto));
} catch (JSONException e) {
Log.error(ProjectCommandManagerDelegate.class, "Unable to parse command of project '" +
project.getPath() + "': " + commandJson + ". " + e.getMessage());
}
}

return new ArrayList<>(commands.values());
Expand Down

0 comments on commit c1ca147

Please sign in to comment.