InvalidRevisionException: Include invalid revision into message
This way we know which revision was invalid when this exception gets logged. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I0f693c63f32abc65bfb83574def1179896724ad9
This commit is contained in:
@@ -19,6 +19,7 @@ import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.entities.Project;
|
||||
import com.google.gerrit.entities.RefNames;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -46,16 +47,16 @@ public class RefUtil {
|
||||
try {
|
||||
ObjectId revid = repo.resolve(baseRevision);
|
||||
if (revid == null) {
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(baseRevision);
|
||||
}
|
||||
return revid;
|
||||
} catch (IOException err) {
|
||||
logger.atSevere().withCause(err).log(
|
||||
"Cannot resolve \"%s\" in project \"%s\"", baseRevision, projectName.get());
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(baseRevision);
|
||||
} catch (RevisionSyntaxException err) {
|
||||
logger.atSevere().withCause(err).log("Invalid revision syntax \"%s\"", baseRevision);
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(baseRevision);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ public class RefUtil {
|
||||
try {
|
||||
rw.markStart(rw.parseCommit(revid));
|
||||
} catch (IncorrectObjectTypeException err) {
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(revid.name());
|
||||
}
|
||||
RefDatabase refDb = repo.getRefDatabase();
|
||||
Iterable<Ref> refs =
|
||||
@@ -86,11 +87,11 @@ public class RefUtil {
|
||||
rw.checkConnectivity();
|
||||
return rw;
|
||||
} catch (IncorrectObjectTypeException | MissingObjectException err) {
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(revid.name());
|
||||
} catch (IOException err) {
|
||||
logger.atSevere().withCause(err).log(
|
||||
"Repository \"%s\" may be corrupt; suggest running git fsck", repo.getDirectory());
|
||||
throw new InvalidRevisionException();
|
||||
throw new InvalidRevisionException(revid.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +126,8 @@ public class RefUtil {
|
||||
|
||||
public static final String MESSAGE = "Invalid Revision";
|
||||
|
||||
InvalidRevisionException() {
|
||||
super(MESSAGE);
|
||||
InvalidRevisionException(@Nullable String invalidRevision) {
|
||||
super(MESSAGE + ": " + invalidRevision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user