Source:
<code><START> private StringBuilder validateParameters() { <END> final StringBuilder err = new StringBuilder(); if (createProjectArgs.getProjectName() == null || createProjectArgs.getProjectName().isEmpty()) { err.append("fatal: Argument NAME is required"); } if (createProjectArgs.getProjectName().contains(" ")) { err.append("project name should not contain whitespaces"); } if (createProjectArgs.getProjectName().endsWith(Constants.DOT_GIT_EXT)) { createProjectArgs.setProjectName(createProjectArgs.getProjectName() .substring( 0, createProjectArgs.getProjectName().length() - Constants.DOT_GIT_EXT.length())); } if (createProjectArgs.getNewParent() != null && !createProjectArgs.getNewParent().getProject().getName().isEmpty()) { final ProjectState state = projectCache.get(new Project.NameKey(createProjectArgs.getNewParent() .getProject().getName())); if (state == null) { err.append("fatal: '" + createProjectArgs.getNewParent() + "': not a Gerrit project"); return err; } } if (!currentUser.getCapabilities().canCreateProject()) { err.append("fatal: Not permitted to create " + createProjectArgs.getProjectName()); return err; } if (createProjectArgs.getOwnerIds() != null && !createProjectArgs.getOwnerIds().isEmpty()) { createProjectArgs.setOwnerIds(new ArrayList<AccountGroup.UUID>( new HashSet<AccountGroup.UUID>(createProjectArgs.getOwnerIds())));; } else { createProjectArgs.setOwnerIds(new ArrayList<AccountGroup.UUID>( projectOwnerGroups)); } while (createProjectArgs.getBranch().startsWith("/")) { createProjectArgs.setBranch(createProjectArgs.getBranch().substring(1)); } if (!createProjectArgs.getBranch().startsWith(Constants.R_HEADS)) { createProjectArgs.setBranch(Constants.R_HEADS + createProjectArgs.getBranch()); } if (!Repository.isValidRefName(createProjectArgs.getBranch())) { err.append("branch \"" + createProjectArgs.getBranch() + "\" is not a valid name"); } return err; }</code><technical_language>I prefer "directly throw ProjectCreationFailedException". Done</technical_language>

Target:
private void validateParameters() throws ProjectCreationFailedException { if (createProjectArgs.getProjectName() == null || createProjectArgs.getProjectName().isEmpty()) { throw new ProjectCreationFailedException( "fatal: project name is required"); } if (createProjectArgs.getProjectName().endsWith(Constants.DOT_GIT_EXT)) { createProjectArgs.setProjectName(createProjectArgs.getProjectName() .substring( 0, createProjectArgs.getProjectName().length() - Constants.DOT_GIT_EXT.length())); } if (!currentUser.getCapabilities().canCreateProject()) { throw new ProjectCreationFailedException(String.format( "%s does not have \"Create Project\" capability.", currentUser.getUserName())); } if (createProjectArgs.ownerIds == null && createProjectArgs.ownerIds.isEmpty()) { createProjectArgs.ownerIds = new ArrayList<AccountGroup.UUID>(projectOwnerGroups); } while (createProjectArgs.branch.startsWith("/")) { createProjectArgs.branch = createProjectArgs.branch.substring(1); } if (!createProjectArgs.branch.startsWith(Constants.R_HEADS)) { createProjectArgs.branch = Constants.R_HEADS + createProjectArgs.branch; } if (!Repository.isValidRefName(createProjectArgs.branch)) { throw new ProjectCreationFailedException(String.format( "Branch \"%s\" is not a valid name.", createProjectArgs.branch)); } }