Merge "Provide descriptive message for NoSuchProjectException"

This commit is contained in:
David Pursehouse
2013-02-18 12:12:03 +00:00
committed by Gerrit Code Review
3 changed files with 5 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
Project.NameKey nameKey = new Project.NameKey(nameWithoutSuffix);
control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
} catch (NoSuchProjectException e) {
throw new CmdLineException(owner, "'" + projectName + "': is not a Gerrit project");
throw new CmdLineException(owner, e.getMessage());
}
setter.addValue(control);

View File

@@ -20,11 +20,13 @@ import com.google.gerrit.reviewdb.client.Project;
public class NoSuchProjectException extends Exception {
private static final long serialVersionUID = 1L;
private static final String MESSAGE = "Project not found: ";
public NoSuchProjectException(final Project.NameKey key) {
this(key, null);
}
public NoSuchProjectException(final Project.NameKey key, final Throwable why) {
super(key.toString(), why);
super(MESSAGE + key.toString(), why);
}
}

View File

@@ -428,7 +428,7 @@ public abstract class BaseCommand implements Command {
try {
thunk.run();
} catch (NoSuchProjectException e) {
throw new UnloggedFailure(1, e.getMessage() + " no such project");
throw new UnloggedFailure(1, e.getMessage());
} catch (NoSuchChangeException e) {
throw new UnloggedFailure(1, e.getMessage() + " no such change");
}