Provide descriptive message for NoSuchProjectException
NoSuchProjectExceptions' message was just the plain project name key, without giving any textual hint, what this means or what had happened. Hence, upon catching the exception, the message had to be reformatted before being shown to the user, even if only a default problem description was needed. The exception's message now states that the respective project could not be found, before giving the project's name key. Change-Id: I901da0a368f9674d0f60100c48da9a6564612c1c
This commit is contained in:
parent
55364017da
commit
88c3263465
@ -65,7 +65,7 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
|
|||||||
Project.NameKey nameKey = new Project.NameKey(nameWithoutSuffix);
|
Project.NameKey nameKey = new Project.NameKey(nameWithoutSuffix);
|
||||||
control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
|
control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
throw new CmdLineException(owner, "'" + projectName + "': is not a Gerrit project");
|
throw new CmdLineException(owner, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
setter.addValue(control);
|
setter.addValue(control);
|
||||||
|
@ -20,11 +20,13 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
public class NoSuchProjectException extends Exception {
|
public class NoSuchProjectException extends Exception {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private static final String MESSAGE = "Project not found: ";
|
||||||
|
|
||||||
public NoSuchProjectException(final Project.NameKey key) {
|
public NoSuchProjectException(final Project.NameKey key) {
|
||||||
this(key, null);
|
this(key, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoSuchProjectException(final Project.NameKey key, final Throwable why) {
|
public NoSuchProjectException(final Project.NameKey key, final Throwable why) {
|
||||||
super(key.toString(), why);
|
super(MESSAGE + key.toString(), why);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ public abstract class BaseCommand implements Command {
|
|||||||
try {
|
try {
|
||||||
thunk.run();
|
thunk.run();
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
throw new UnloggedFailure(1, e.getMessage() + " no such project");
|
throw new UnloggedFailure(1, e.getMessage());
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
throw new UnloggedFailure(1, e.getMessage() + " no such change");
|
throw new UnloggedFailure(1, e.getMessage() + " no such change");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user