summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Kempin <ekempin@google.com>2019-12-05 10:26:57 +0100
committerDavid Pursehouse <dpursehouse@collab.net>2019-12-06 09:36:58 +0900
commit822e544ac4fc1a02cc31f7f3c1a13a2db5149624 (patch)
treeec6ffd58a3d20f471df7aa7339daa970ffd97de2
parent1a9610aedbbe1e1bf868958f3fa373b0732006f9 (diff)
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
-rw-r--r--java/com/google/gerrit/server/project/RefUtil.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/java/com/google/gerrit/server/project/RefUtil.java b/java/com/google/gerrit/server/project/RefUtil.java
index 9f1fa4a21c..696190b94f 100644
--- a/java/com/google/gerrit/server/project/RefUtil.java
+++ b/java/com/google/gerrit/server/project/RefUtil.java
@@ -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.extensions.restapi.BadRequestException;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
@@ -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);
}
}
}