Source:
<code>public void createProject() throws ProjectCreationFailedException { validateParameters(); try { final Project.NameKey nameKey = createProjectArgs.getProject(); final String head = createProjectArgs.permissionsOnly ? GitRepositoryManager.REF_CONFIG : createProjectArgs.branch; final Repository repo; try { repo = repoManager.createRepository(nameKey); } catch (RepositoryCaseMismatchException err) { throw new ProjectCreationFailedException("Cannot create " + nameKey.get() + " because the name is already occupied by another project." + " The other project has the same name, only spelled in a" + " different case.", err); } try { replication.replicateNewProject(nameKey, head); final RefUpdate u = repo.updateRef(Constants.HEAD); u.disableRefLog(); u.link(head); createProjectConfig(); if (!createProjectArgs.permissionsOnly && createProjectArgs.createEmptyCommit) { createEmptyCommit(repo, nameKey, createProjectArgs.branch); } } finally { repo.close(); } <START> } catch (Exception e) { <END> final String msg = "Cannot create " + createProjectArgs.getProject(); log.error(msg, e); throw new ProjectCreationFailedException(msg, e); } }</code><technical_language>afraid exception handling is simple. create-project command fails, error message is shown user is "Cannot create ...". I for error message more specific differentiate cases: project exists already, project exists in another case, project created due some other reason. care write entry error log if a real error (e.g. if user invalid repository name, I log this)</technical_language>

Target:
public void createProject() throws ProjectCreationFailedException { validateParameters(); final Project.NameKey nameKey = createProjectArgs.getProject(); try { final String head = createProjectArgs.permissionsOnly ? GitRepositoryManager.REF_CONFIG : createProjectArgs.branch; final Repository repo = repoManager.createRepository(nameKey); try { replication.replicateNewProject(nameKey, head); final RefUpdate u = repo.updateRef(Constants.HEAD); u.disableRefLog(); u.link(head); createProjectConfig(); if (!createProjectArgs.permissionsOnly && createProjectArgs.createEmptyCommit) { createEmptyCommit(repo, nameKey, createProjectArgs.branch); } } finally { repo.close(); } } catch (RepositoryCaseMismatchException e) { throw new ProjectCreationFailedException("Cannot create " + nameKey.get() + " because the name is already occupied by another project." + " The other project has the same name, only spelled in a" + " different case.", e); } catch (RepositoryNotFoundException badName) { throw new ProjectCreationFailedException("Cannot create " + nameKey, badName); } catch (IllegalStateException err) { try { final Repository repo = repoManager.openRepository(nameKey); try { if (repo.getObjectDatabase().exists()) { throw new ProjectCreationFailedException("project \"" + nameKey + "\" exists"); } } finally { repo.close(); } } catch (RepositoryNotFoundException doesNotExist) { final String msg = "Cannot create " + nameKey; log.error(msg, err); throw new ProjectCreationFailedException(msg, err); } } catch (Exception e) { final String msg = "Cannot create " + nameKey; log.error(msg, e); throw new ProjectCreationFailedException(msg, e); } }