Merge branch 'stable-3.1'
* stable-3.1: Update git submodules Update git submodules ErrorProne: Enable and fix UnusedException check Update git submodules Update git submodules Also fix a few more instances of UnusedException. Change-Id: Ib3f05bb8f779f83712c6259522c26b42e93ea44b
This commit is contained in:
commit
0d22e9a9d7
@ -232,7 +232,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
||||
try {
|
||||
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
|
||||
} catch (AuthException e) {
|
||||
throw new ServiceNotAuthorizedException();
|
||||
throw new ServiceNotAuthorizedException(e.getMessage(), e);
|
||||
} catch (PermissionBackendException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -307,7 +307,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
||||
.project(req.project)
|
||||
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
||||
} catch (AuthException e) {
|
||||
throw new ServiceNotAuthorizedException();
|
||||
throw new ServiceNotAuthorizedException(e.getMessage(), e);
|
||||
} catch (PermissionBackendException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -220,8 +220,11 @@ public abstract class StandaloneSiteTest {
|
||||
try {
|
||||
status = p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException(
|
||||
"interrupted waiting for: " + Joiner.on(' ').join(pb.command()));
|
||||
InterruptedIOException iioe =
|
||||
new InterruptedIOException(
|
||||
"interrupted waiting for: " + Joiner.on(' ').join(pb.command()));
|
||||
iioe.initCause(e);
|
||||
throw iioe;
|
||||
}
|
||||
|
||||
String result = new String(out, UTF_8);
|
||||
|
@ -97,7 +97,7 @@ public class KeyUtil {
|
||||
}
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException err) {
|
||||
throw new IllegalArgumentException("Bad encoding: " + e);
|
||||
throw new IllegalArgumentException("Bad encoding" + e, err);
|
||||
}
|
||||
try {
|
||||
return new String(b, 0, bPtr, "UTF-8");
|
||||
|
@ -23,4 +23,8 @@ public class InvalidSshKeyException extends Exception {
|
||||
public InvalidSshKeyException() {
|
||||
super(MESSAGE);
|
||||
}
|
||||
|
||||
public InvalidSshKeyException(Throwable cause) {
|
||||
super(MESSAGE, cause);
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,12 @@ public class MethodNotAllowedException extends RestApiException {
|
||||
public MethodNotAllowedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg error text for client describing why the method is not allowed.
|
||||
* @param cause reason for the method not being allowed.
|
||||
*/
|
||||
public MethodNotAllowedException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,8 @@ public class NotImplementedException extends UnsupportedOperationException {
|
||||
public NotImplementedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NotImplementedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public class ResourceNotFoundException extends RestApiException {
|
||||
super("Not found: " + id.get());
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(IdString id, Throwable cause) {
|
||||
super("Not found: " + id.get(), cause);
|
||||
}
|
||||
|
||||
public ResourceNotFoundException caching(CacheControl c) {
|
||||
setCaching(c);
|
||||
return this;
|
||||
|
@ -131,7 +131,7 @@ public class HtmlDomUtil {
|
||||
try {
|
||||
d = newBuilder().newDocument();
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new IOException("Cannot clone document");
|
||||
throw new IOException("Cannot clone document", e);
|
||||
}
|
||||
Node n = d.importNode(doc.getDocumentElement(), true);
|
||||
d.appendChild(n);
|
||||
|
@ -195,7 +195,7 @@ class ProjectOAuthFilter implements Filter {
|
||||
defaultAuthPlugin = loginProvider.getPluginName();
|
||||
defaultAuthProvider = loginProvider.getExportName();
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new ServletException("No OAuth login provider installed");
|
||||
throw new ServletException("No OAuth login provider installed", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// multiple providers found => do not pick any
|
||||
}
|
||||
|
@ -61,9 +61,11 @@ class PluginServletContext {
|
||||
try {
|
||||
handler = API.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new NoSuchMethodError(
|
||||
String msg =
|
||||
String.format(
|
||||
"%s does not implement %s", PluginServletContext.class, method.toGenericString()));
|
||||
"%s does not implement %s", PluginServletContext.class, method.toGenericString());
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw new NoSuchMethodError(msg);
|
||||
}
|
||||
return handler.invoke(this, args);
|
||||
}
|
||||
|
@ -63,8 +63,9 @@ public class BazelBuild {
|
||||
try {
|
||||
status = rebuild.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
throw new InterruptedIOException(
|
||||
"interrupted waiting for: " + Joiner.on(' ').join(proc.command()));
|
||||
String msg = "interrupted waiting for: " + Joiner.on(' ').join(proc.command());
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw new InterruptedIOException(msg);
|
||||
}
|
||||
if (status != 0) {
|
||||
logger.atWarning().log("build failed: %s", new String(out, UTF_8));
|
||||
|
@ -1182,7 +1182,7 @@ public class RestApiServlet extends HttpServlet {
|
||||
try {
|
||||
first = json.peek();
|
||||
} catch (EOFException e) {
|
||||
throw new BadRequestException("Expected JSON object");
|
||||
throw new BadRequestException("Expected JSON object", e);
|
||||
}
|
||||
if (first == JsonToken.STRING) {
|
||||
return parseString(json.nextString(), type);
|
||||
|
@ -208,7 +208,7 @@ public class QueryBuilder<V> {
|
||||
// subclasses of OperatorPredicate.
|
||||
value = Integer.parseInt(p.getValue());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new QueryParseException("not an integer: " + p.getValue());
|
||||
throw new QueryParseException("not an integer: " + p.getValue(), e);
|
||||
}
|
||||
return intTermQuery.get(p.getField().getName(), value);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public class BaseInit extends SiteProgram {
|
||||
IoUtil.loadJARs(secureStoreLib);
|
||||
return new SecureStoreInitData(secureStoreLib, secureStores.get(0));
|
||||
} catch (IOException e) {
|
||||
throw new InvalidSecureStoreException(String.format("%s is not a valid jar", secureStore));
|
||||
throw new InvalidSecureStoreException(String.format("%s is not a valid jar", secureStore), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class InitHttpd implements InitStep {
|
||||
uri = new URI(s + "://" + uri.getHost() + uri.getPath());
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw die("invalid httpd.listenUrl");
|
||||
throw die("invalid httpd.listenUrl", e);
|
||||
}
|
||||
httpd.set("listenUrl", urlbuf.toString());
|
||||
gerrit.string("Canonical URL", "canonicalWebUrl", uri.toString());
|
||||
|
@ -331,7 +331,7 @@ public class ApprovalsUtil {
|
||||
forChange.check(new LabelPermission.WithValue(name, value));
|
||||
} catch (AuthException e) {
|
||||
throw new AuthException(
|
||||
String.format("applying label \"%s\": %d is restricted", name, value));
|
||||
String.format("applying label \"%s\": %d is restricted", name, value), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public class AccountManager {
|
||||
try {
|
||||
groupsUpdate.updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new AccountException(String.format("Group %s not found", groupUuid));
|
||||
throw new AccountException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.entities.Account;
|
||||
@ -43,6 +44,8 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
@AutoValue
|
||||
public abstract class ExternalId implements Serializable {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
// If these regular expressions are modified the same modifications should be done to the
|
||||
// corresponding regular expressions in the
|
||||
// com.google.gerrit.client.account.UsernameField class.
|
||||
@ -391,11 +394,12 @@ public abstract class ExternalId implements Serializable {
|
||||
}
|
||||
return accountId;
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw invalidConfig(
|
||||
noteId,
|
||||
String msg =
|
||||
String.format(
|
||||
"Value %s for '%s.%s.%s' is invalid, expected account ID",
|
||||
accountIdStr, EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY));
|
||||
accountIdStr, EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY);
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw invalidConfig(noteId, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
@ -38,6 +39,8 @@ import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final AccountResolver accountResolver;
|
||||
private final AccountManager accountManager;
|
||||
private final AuthType authType;
|
||||
@ -78,11 +81,15 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
case OPENID:
|
||||
case OPENID_SSO:
|
||||
default:
|
||||
throw new CmdLineException(owner, localizable("user \"%s\" not found"), token);
|
||||
String msg = "user \"%s\" not found";
|
||||
logger.atSevere().withCause(e).log(msg, token);
|
||||
throw new CmdLineException(owner, localizable(msg), token);
|
||||
}
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("database is down"));
|
||||
String msg = "database is down";
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw new CmdLineException(owner, localizable(msg));
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(owner, "Failed to load account", e);
|
||||
} catch (ConfigInvalidException e) {
|
||||
@ -102,7 +109,9 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
req.setSkipAuthentication(true);
|
||||
return accountManager.authenticate(req).getAccountId();
|
||||
} catch (AccountException e) {
|
||||
throw new CmdLineException(owner, localizable("user \"%s\" not found"), user);
|
||||
String msg = "user \"%s\" not found";
|
||||
logger.atSevere().withCause(e).log(msg, user);
|
||||
throw new CmdLineException(owner, localizable(msg), user);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class ChangeIdHandler extends OptionHandler<Change.Id> {
|
||||
return 1;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CmdLineException(owner, localizable("Change-Id is not valid"));
|
||||
throw new CmdLineException(owner, localizable("Change-Id is not valid: %s"), e.getMessage());
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ public class PatchSetIdHandler extends OptionHandler<PatchSet.Id> {
|
||||
try {
|
||||
id = PatchSet.Id.parse(token);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CmdLineException(owner, localizable("\"%s\" is not a valid patch set"), token);
|
||||
throw new CmdLineException(
|
||||
owner, localizable("\"%s\" is not a valid patch set: %s"), token, e.getMessage());
|
||||
}
|
||||
|
||||
setter.addValue(id);
|
||||
|
@ -89,7 +89,7 @@ public class ProjectHandler extends OptionHandler<ProjectState> {
|
||||
permissionBackend.currentUser().project(nameKey).check(permissionToCheck);
|
||||
} catch (AuthException e) {
|
||||
throw new CmdLineException(
|
||||
owner, localizable(new NoSuchProjectException(nameKey).getMessage()));
|
||||
owner, localizable(new NoSuchProjectException(nameKey, e).getMessage()));
|
||||
} catch (PermissionBackendException | IOException e) {
|
||||
logger.atWarning().withCause(e).log("Cannot load project %s", nameWithoutSuffix);
|
||||
throw new CmdLineException(
|
||||
|
@ -37,7 +37,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
||||
cout.writeInt32NoTag(requireNonNull(object));
|
||||
cout.flush();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to serialize int");
|
||||
throw new IllegalStateException("Failed to serialize int", e);
|
||||
}
|
||||
int n = cout.getTotalBytesWritten();
|
||||
return n == buf.length ? buf : Arrays.copyOfRange(buf, 0, n);
|
||||
@ -50,7 +50,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
||||
try {
|
||||
ret = cin.readRawVarint32();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Failed to deserialize int");
|
||||
throw new IllegalArgumentException("Failed to deserialize int", e);
|
||||
}
|
||||
int n = cin.getTotalBytesRead();
|
||||
if (n != in.length) {
|
||||
|
@ -50,7 +50,7 @@ public class PureRevert {
|
||||
try {
|
||||
claimedOriginalObjectId = ObjectId.fromString(claimedOriginal.get());
|
||||
} catch (InvalidObjectIdException e) {
|
||||
throw new BadRequestException("invalid object ID");
|
||||
throw new BadRequestException("invalid object ID", e);
|
||||
}
|
||||
|
||||
return pureRevertCache.isPureRevert(
|
||||
|
@ -30,7 +30,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
public class ConfigUtil {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T[] allValuesOf(T defaultValue) {
|
||||
try {
|
||||
@ -182,7 +181,7 @@ public class ConfigUtil {
|
||||
try {
|
||||
return getTimeUnit(s, defaultValue, wantUnit);
|
||||
} catch (IllegalArgumentException notTime) {
|
||||
throw notTimeUnit(section, subsection, setting, valueString);
|
||||
throw notTimeUnit(section, subsection, setting, valueString, notTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +249,7 @@ public class ConfigUtil {
|
||||
try {
|
||||
return wantUnit.convert(Long.parseLong(digits) * inputMul, inputUnit);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw notTimeUnit(valueString);
|
||||
throw notTimeUnit(valueString, nfe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,13 +420,21 @@ public class ConfigUtil {
|
||||
}
|
||||
|
||||
private static IllegalArgumentException notTimeUnit(
|
||||
final String section,
|
||||
final String subsection,
|
||||
final String setting,
|
||||
final String valueString) {
|
||||
return new IllegalArgumentException(
|
||||
"Invalid time unit value: "
|
||||
+ section
|
||||
String section, String subsection, String setting, String valueString, Throwable why) {
|
||||
return notTimeUnit(
|
||||
section
|
||||
+ (subsection != null ? "." + subsection : "")
|
||||
+ "."
|
||||
+ setting
|
||||
+ " = "
|
||||
+ valueString,
|
||||
why);
|
||||
}
|
||||
|
||||
private static IllegalArgumentException notTimeUnit(
|
||||
String section, String subsection, String setting, String valueString) {
|
||||
return notTimeUnit(
|
||||
section
|
||||
+ (subsection != null ? "." + subsection : "")
|
||||
+ "."
|
||||
+ setting
|
||||
@ -439,5 +446,9 @@ public class ConfigUtil {
|
||||
return new IllegalArgumentException("Invalid time unit value: " + val);
|
||||
}
|
||||
|
||||
private static IllegalArgumentException notTimeUnit(String val, Throwable why) {
|
||||
return new IllegalArgumentException("Invalid time unit value: " + val, why);
|
||||
}
|
||||
|
||||
private ConfigUtil() {}
|
||||
}
|
||||
|
@ -760,6 +760,7 @@ public class MergeUtil {
|
||||
try {
|
||||
failed(rw, mergeTip, n, getCommitMergeStatus(e.getReason()));
|
||||
} catch (IOException e2) {
|
||||
logger.atSevere().withCause(e2).log("Failed to set merge failure status for " + n.name());
|
||||
throw new IntegrationException("Cannot merge " + n.name(), e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -106,7 +106,7 @@ public class PermissionAwareReadOnlyRefDatabase extends DelegateRefDatabase {
|
||||
try {
|
||||
result = forProject.filter(refs, getDelegate(), RefFilterOptions.defaults());
|
||||
} catch (PermissionBackendException e) {
|
||||
throw new IOException("");
|
||||
throw new IOException("", e);
|
||||
}
|
||||
return buildPrefixRefMap(prefix, result);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public class PureRevertCache {
|
||||
try {
|
||||
claimedOriginalCommit = rw.parseCommit(original);
|
||||
} catch (InvalidObjectIdException | MissingObjectException e) {
|
||||
throw new BadRequestException("invalid object ID");
|
||||
throw new BadRequestException("invalid object ID", e);
|
||||
}
|
||||
if (claimedOriginalCommit.getParentCount() == 0) {
|
||||
throw new BadRequestException("can't check against initial commit");
|
||||
|
@ -32,6 +32,11 @@ public class CommitValidationException extends ValidationException {
|
||||
this.messages = ImmutableList.of(message);
|
||||
}
|
||||
|
||||
public CommitValidationException(String reason, CommitValidationMessage message, Throwable why) {
|
||||
super(reason, why);
|
||||
this.messages = ImmutableList.of(message);
|
||||
}
|
||||
|
||||
public CommitValidationException(String reason, List<CommitValidationMessage> messages) {
|
||||
super(reason);
|
||||
this.messages = ImmutableList.copyOf(messages);
|
||||
|
@ -500,7 +500,7 @@ public class CommitValidators {
|
||||
perm.check(RefPermission.MERGE);
|
||||
return Collections.emptyList();
|
||||
} catch (AuthException e) {
|
||||
throw new CommitValidationException("you are not allowed to upload merges");
|
||||
throw new CommitValidationException("you are not allowed to upload merges", e);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("cannot check MERGE");
|
||||
throw new CommitValidationException("internal auth error");
|
||||
@ -597,7 +597,7 @@ public class CommitValidators {
|
||||
perm.check(RefPermission.FORGE_COMMITTER);
|
||||
} catch (AuthException denied) {
|
||||
throw new CommitValidationException(
|
||||
"not Signed-off-by author/committer/uploader in message footer");
|
||||
"not Signed-off-by author/committer/uploader in message footer", denied);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
||||
throw new CommitValidationException("internal auth error");
|
||||
@ -632,7 +632,7 @@ public class CommitValidators {
|
||||
return Collections.emptyList();
|
||||
} catch (AuthException e) {
|
||||
throw new CommitValidationException(
|
||||
"invalid author", invalidEmail("author", author, user, urlFormatter));
|
||||
"invalid author", invalidEmail("author", author, user, urlFormatter), e);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("cannot check FORGE_AUTHOR");
|
||||
throw new CommitValidationException("internal auth error");
|
||||
@ -665,7 +665,7 @@ public class CommitValidators {
|
||||
return Collections.emptyList();
|
||||
} catch (AuthException e) {
|
||||
throw new CommitValidationException(
|
||||
"invalid committer", invalidEmail("committer", committer, user, urlFormatter));
|
||||
"invalid committer", invalidEmail("committer", committer, user, urlFormatter), e);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
||||
throw new CommitValidationException("internal auth error");
|
||||
@ -704,7 +704,8 @@ public class CommitValidators {
|
||||
"pushing merge commit %s by %s requires '%s' permission",
|
||||
receiveEvent.commit.getId(),
|
||||
gerritIdent.getEmailAddress(),
|
||||
RefPermission.FORGE_SERVER.name()));
|
||||
RefPermission.FORGE_SERVER.name()),
|
||||
denied);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("cannot check FORGE_SERVER");
|
||||
throw new CommitValidationException("internal auth error");
|
||||
|
@ -28,4 +28,8 @@ public class MergeValidationException extends ValidationException {
|
||||
public MergeValidationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public MergeValidationException(String msg, Throwable why) {
|
||||
super(msg, why);
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class MergeValidators {
|
||||
try {
|
||||
permissionBackend.user(caller).check(GlobalPermission.ADMINISTRATE_SERVER);
|
||||
} catch (AuthException e) {
|
||||
throw new MergeValidationException(SET_BY_ADMIN);
|
||||
throw new MergeValidationException(SET_BY_ADMIN, e);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atWarning().withCause(e).log("Cannot check ADMINISTRATE_SERVER");
|
||||
throw new MergeValidationException("validation unavailable");
|
||||
@ -204,7 +204,7 @@ public class MergeValidators {
|
||||
.project(destProject.getNameKey())
|
||||
.check(ProjectPermission.WRITE_CONFIG);
|
||||
} catch (AuthException e) {
|
||||
throw new MergeValidationException(SET_BY_OWNER);
|
||||
throw new MergeValidationException(SET_BY_OWNER, e);
|
||||
} catch (PermissionBackendException e) {
|
||||
logger.atWarning().withCause(e).log("Cannot check WRITE_CONFIG");
|
||||
throw new MergeValidationException("validation unavailable");
|
||||
@ -245,7 +245,7 @@ public class MergeValidators {
|
||||
}
|
||||
}
|
||||
} catch (ConfigInvalidException | IOException e) {
|
||||
throw new MergeValidationException(INVALID_CONFIG);
|
||||
throw new MergeValidationException(INVALID_CONFIG, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class RefOperationValidators {
|
||||
try {
|
||||
perm.check(GlobalPermission.ACCESS_DATABASE);
|
||||
} catch (AuthException | PermissionBackendException e) {
|
||||
throw new ValidationException("Not allowed to create user branch.");
|
||||
throw new ValidationException("Not allowed to create user branch.", e);
|
||||
}
|
||||
if (Account.Id.fromRef(refEvent.command.getRefName()) == null) {
|
||||
throw new ValidationException(
|
||||
@ -145,7 +145,7 @@ public class RefOperationValidators {
|
||||
try {
|
||||
perm.check(GlobalPermission.ACCESS_DATABASE);
|
||||
} catch (AuthException | PermissionBackendException e) {
|
||||
throw new ValidationException("Not allowed to delete user branch.");
|
||||
throw new ValidationException("Not allowed to delete user branch.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
try {
|
||||
ps = args.patchSetUtil.get(changeData.notes(), PatchSet.id(change.getId(), patchSetId));
|
||||
} catch (StorageException e) {
|
||||
throw new PatchListNotAvailableException("Failed to get patchSet");
|
||||
throw new PatchListNotAvailableException("Failed to get patchSet", e);
|
||||
}
|
||||
}
|
||||
return args.patchListCache.get(change, ps);
|
||||
|
@ -907,7 +907,9 @@ class ChangeNotesParser {
|
||||
try {
|
||||
adr = Address.parse(line);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw invalidFooter(state.getByEmailFooterKey(), line);
|
||||
ConfigInvalidException cie = invalidFooter(state.getByEmailFooterKey(), line);
|
||||
cie.initCause(e);
|
||||
throw cie;
|
||||
}
|
||||
if (!reviewersByEmail.containsRow(adr)) {
|
||||
reviewersByEmail.put(adr, state, ts);
|
||||
|
@ -193,7 +193,7 @@ public class PatchScriptFactory implements Callable<PatchScript> {
|
||||
try {
|
||||
permissionBackend.currentUser().change(notes).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
throw new NoSuchChangeException(changeId, e);
|
||||
}
|
||||
|
||||
if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) {
|
||||
|
@ -98,7 +98,7 @@ public class PatchScriptFactoryForAutoFix implements Callable<PatchScript> {
|
||||
try {
|
||||
permissionBackend.currentUser().change(notes).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
throw new NoSuchChangeException(changeId, e);
|
||||
}
|
||||
|
||||
if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) {
|
||||
|
@ -132,9 +132,10 @@ public class ProjectCreator {
|
||||
+ nameKey.get()
|
||||
+ " because the name is already occupied by another project."
|
||||
+ " The other project has the same name, only spelled in a"
|
||||
+ " different case.");
|
||||
+ " different case.",
|
||||
e);
|
||||
} catch (RepositoryNotFoundException badName) {
|
||||
throw new BadRequestException("invalid project name: " + nameKey);
|
||||
throw new BadRequestException("invalid project name: " + nameKey, badName);
|
||||
} catch (ConfigInvalidException e) {
|
||||
String msg = "Cannot create " + nameKey;
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
|
@ -55,7 +55,7 @@ public class RefUtil {
|
||||
"Cannot resolve \"%s\" in project \"%s\"", baseRevision, projectName.get());
|
||||
throw new InvalidRevisionException(baseRevision);
|
||||
} catch (RevisionSyntaxException err) {
|
||||
throw new InvalidRevisionException(baseRevision);
|
||||
throw new InvalidRevisionException(baseRevision, err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public class RefUtil {
|
||||
try {
|
||||
rw.markStart(rw.parseCommit(revid));
|
||||
} catch (IncorrectObjectTypeException err) {
|
||||
throw new InvalidRevisionException(revid.name());
|
||||
throw new InvalidRevisionException(revid.name(), err);
|
||||
}
|
||||
RefDatabase refDb = repo.getRefDatabase();
|
||||
Iterable<Ref> refs =
|
||||
@ -86,7 +86,7 @@ public class RefUtil {
|
||||
rw.checkConnectivity();
|
||||
return rw;
|
||||
} catch (IncorrectObjectTypeException | MissingObjectException err) {
|
||||
throw new InvalidRevisionException(revid.name());
|
||||
throw new InvalidRevisionException(revid.name(), err);
|
||||
} catch (IOException err) {
|
||||
logger.atSevere().withCause(err).log(
|
||||
"Repository \"%s\" may be corrupt; suggest running git fsck", repo.getDirectory());
|
||||
@ -128,5 +128,9 @@ public class RefUtil {
|
||||
InvalidRevisionException(@Nullable String invalidRevision) {
|
||||
super(MESSAGE + ": " + invalidRevision);
|
||||
}
|
||||
|
||||
InvalidRevisionException(@Nullable String invalidRevision, Throwable why) {
|
||||
super(MESSAGE + ": " + invalidRevision, why);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,9 @@ public class AccountQueryBuilder extends QueryBuilder<AccountState, AccountQuery
|
||||
try {
|
||||
args.permissionBackend.user(args.getUser()).change(changeNotes).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw error(String.format("change %s not found", change));
|
||||
String msg = String.format("change %s not found", change);
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw error(msg);
|
||||
}
|
||||
|
||||
return AccountPredicates.cansee(args, changeNotes);
|
||||
|
@ -1288,7 +1288,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData, ChangeQueryBuil
|
||||
throw new QueryParseException(
|
||||
"'"
|
||||
+ value
|
||||
+ "' is not a valid input. It must be in the 'ChangeNumber[,PatchsetNumber]' format.");
|
||||
+ "' is not a valid input. It must be in the 'ChangeNumber[,PatchsetNumber]' format.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
throw new QueryParseException(
|
||||
|
@ -75,7 +75,7 @@ public class ProjectQueryBuilder extends QueryBuilder<ProjectData, ProjectQueryB
|
||||
try {
|
||||
parsedState = ProjectState.valueOf(state.replace('-', '_').toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw error("state operator must be either 'active' or 'read-only'");
|
||||
throw error("state operator must be either 'active' or 'read-only'", e);
|
||||
}
|
||||
if (parsedState == ProjectState.HIDDEN) {
|
||||
throw error("state operator must be either 'active' or 'read-only'");
|
||||
|
@ -75,7 +75,7 @@ public class Capabilities implements ChildCollection<AccountResource, AccountRes
|
||||
permissionBackend.absentUser(target.getAccountId()).check(perm);
|
||||
return new AccountResource.Capability(target, globalOrPluginPermissionName(perm));
|
||||
} catch (AuthException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class CreateAccount
|
||||
try {
|
||||
addGroupMember(groupUuid, accountId);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new UnprocessableEntityException(String.format("Group %s not found", groupUuid));
|
||||
throw new UnprocessableEntityException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class PutAgreement implements RestModifyView<AccountResource, AgreementIn
|
||||
try {
|
||||
addMembers.addMembers(uuid, ImmutableSet.of(accountState.account().id()));
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceConflictException("autoverify group not found");
|
||||
throw new ResourceConflictException("autoverify group not found", e);
|
||||
}
|
||||
agreementSignup.fire(accountState, agreementName);
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class PutUsername implements RestModifyView<AccountResource, UsernameInpu
|
||||
}
|
||||
|
||||
// Otherwise, someone else has this identity.
|
||||
throw new ResourceConflictException("username already used");
|
||||
throw new ResourceConflictException("username already used", dupeErr);
|
||||
}
|
||||
|
||||
sshKeyCache.evict(input.username);
|
||||
|
@ -70,7 +70,7 @@ public class SshKeys implements ChildCollection<AccountResource, AccountResource
|
||||
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
|
||||
} catch (AuthException e) {
|
||||
// If lacking MODIFY_ACCOUNT claim the resource does not exist.
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
return parse(rsrc.getUser(), id);
|
||||
@ -86,7 +86,7 @@ public class SshKeys implements ChildCollection<AccountResource, AccountResource
|
||||
}
|
||||
return new AccountResource.SshKey(user, sshKey);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,10 @@ public class StarredChanges
|
||||
try {
|
||||
change = changes.parse(TopLevelResource.INSTANCE, id);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
throw new UnprocessableEntityException(String.format("change %s not found", id.get()));
|
||||
throw new UnprocessableEntityException(String.format("change %s not found", id.get()), e);
|
||||
} catch (StorageException | PermissionBackendException | IOException e) {
|
||||
logger.atSevere().withCause(e).log("cannot resolve change");
|
||||
throw new UnprocessableEntityException("internal server error");
|
||||
throw new UnprocessableEntityException("internal server error", e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -422,7 +422,8 @@ public class CherryPickChange {
|
||||
try {
|
||||
baseObjectId = ObjectId.fromString(base);
|
||||
} catch (InvalidObjectIdException e) {
|
||||
throw new BadRequestException(String.format("Base %s doesn't represent a valid SHA-1", base));
|
||||
throw new BadRequestException(
|
||||
String.format("Base %s doesn't represent a valid SHA-1", base), e);
|
||||
}
|
||||
|
||||
RevCommit baseCommit;
|
||||
|
@ -205,7 +205,7 @@ public class CreateMergePatchSet implements RestModifyView<ChangeResource, Merge
|
||||
try {
|
||||
permissionBackend.currentUser().change(change).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new UnprocessableEntityException("Read not permitted for " + baseChange);
|
||||
throw new UnprocessableEntityException("Read not permitted for " + baseChange, e);
|
||||
}
|
||||
return psUtil.current(change);
|
||||
}
|
||||
|
@ -293,6 +293,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
logger.atFine().withCause(e).log("invalid numeric value");
|
||||
throw new CmdLineException(
|
||||
owner,
|
||||
localizable("\"%s\" is not a valid value for \"%s\""),
|
||||
|
@ -514,7 +514,8 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
throw new AuthException(
|
||||
String.format(
|
||||
"not permitted to modify label \"%s\" on behalf of \"%s\"",
|
||||
type.getName(), in.onBehalfOf));
|
||||
type.getName(), in.onBehalfOf),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -530,7 +531,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
permissionBackend.user(reviewer).change(rev.getNotes()).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new UnprocessableEntityException(
|
||||
String.format("on_behalf_of account %s cannot see change", reviewer.getAccountId()));
|
||||
String.format("on_behalf_of account %s cannot see change", reviewer.getAccountId()), e);
|
||||
}
|
||||
|
||||
return new RevisionResource(
|
||||
@ -580,7 +581,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
perm.check(new LabelPermission.WithValue(lt, val));
|
||||
} catch (AuthException e) {
|
||||
throw new AuthException(
|
||||
String.format("Applying label \"%s\": %d is restricted", lt.getName(), val));
|
||||
String.format("Applying label \"%s\": %d is restricted", lt.getName(), val), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class PreviewSubmit implements RestReadView<RevisionResource> {
|
||||
archiveFormat.putEntry(aos, path, bos.toByteArray());
|
||||
}
|
||||
} catch (LimitExceededException e) {
|
||||
throw new NotImplementedException("The bundle is too big to generate at the server");
|
||||
throw new NotImplementedException("The bundle is too big to generate at the server", e);
|
||||
} catch (NoSuchProjectException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class PutAssignee
|
||||
.change(rsrc.getNotes())
|
||||
.check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new AuthException("read not permitted for " + input.assignee);
|
||||
throw new AuthException("read not permitted for " + input.assignee, e);
|
||||
}
|
||||
|
||||
try (BatchUpdate bu =
|
||||
|
@ -129,7 +129,7 @@ public class QueryChanges implements RestReadView<TopLevelResource>, DynamicOpti
|
||||
try {
|
||||
out = query();
|
||||
} catch (QueryRequiresAuthException e) {
|
||||
throw new AuthException("Must be signed-in to use this operator");
|
||||
throw new AuthException("Must be signed-in to use this operator", e);
|
||||
} catch (QueryParseException e) {
|
||||
logger.atFine().withCause(e).log("Reject change query with 400 Bad Request: %s", queries);
|
||||
throw new BadRequestException(e.getMessage(), e);
|
||||
|
@ -438,7 +438,7 @@ public class Submit
|
||||
permissionBackend.user(submitter).change(rsrc.getNotes()).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
throw new UnprocessableEntityException(
|
||||
String.format("on_behalf_of account %s cannot see change", submitter.getAccountId()));
|
||||
String.format("on_behalf_of account %s cannot see change", submitter.getAccountId()), e);
|
||||
}
|
||||
return submitter;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class ConfirmEmail implements RestModifyView<ConfigResource, Input> {
|
||||
}
|
||||
throw new UnprocessableEntityException("invalid token");
|
||||
} catch (EmailTokenVerifier.InvalidTokenException e) {
|
||||
throw new UnprocessableEntityException("invalid token");
|
||||
throw new UnprocessableEntityException("invalid token", e);
|
||||
} catch (AccountException e) {
|
||||
throw new UnprocessableEntityException(e.getMessage());
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class TasksCollection implements ChildCollection<ConfigResource, TaskReso
|
||||
try {
|
||||
taskId = (int) Long.parseLong(id.get(), 16);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
|
||||
Task<?> task = workQueue.getTask(taskId);
|
||||
|
@ -138,7 +138,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
try {
|
||||
addMembers(groupUuid, newMemberIds);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
return Response.ok(toAccountInfoList(newMemberIds));
|
||||
}
|
||||
@ -234,7 +234,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
|
||||
try {
|
||||
addSubgroups(groupUuid, subgroupUuids);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
return Response.ok(result);
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public class CreateGroup
|
||||
return groupsUpdateProvider.get().createGroup(groupCreation, groupUpdateBuilder.build());
|
||||
} catch (DuplicateKeyException e) {
|
||||
throw new ResourceConflictException(
|
||||
"group '" + createGroupArgs.getGroupName() + "' already exists");
|
||||
"group '" + createGroupArgs.getGroupName() + "' already exists", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
try {
|
||||
removeGroupMembers(groupUuid, membersToRemove);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
|
||||
return Response.none();
|
||||
|
@ -77,7 +77,7 @@ public class DeleteSubgroups implements RestModifyView<GroupResource, Input> {
|
||||
try {
|
||||
removeSubgroups(groupUuid, subgroupsToRemove);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
|
||||
return Response.none();
|
||||
|
@ -47,7 +47,7 @@ public class GetOwner implements RestReadView<GroupResource> {
|
||||
GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
|
||||
return Response.ok(json.format(c.getGroup()));
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(group.getOwnerGroupUUID().get(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class PutDescription implements RestModifyView<GroupResource, Description
|
||||
try {
|
||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,9 +79,9 @@ public class PutName implements RestModifyView<GroupResource, NameInput> {
|
||||
try {
|
||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
} catch (DuplicateKeyException e) {
|
||||
throw new ResourceConflictException("group with name " + newName + " already exists");
|
||||
throw new ResourceConflictException("group with name " + newName + " already exists", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class PutOptions implements RestModifyView<GroupResource, GroupOptionsInf
|
||||
try {
|
||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class PutOwner implements RestModifyView<GroupResource, OwnerInput> {
|
||||
try {
|
||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||
}
|
||||
}
|
||||
return Response.ok(json.format(owner));
|
||||
|
@ -82,9 +82,9 @@ public class BranchesCollection implements ChildCollection<ProjectResource, Bran
|
||||
.check(RefPermission.READ);
|
||||
return new BranchResource(parent.getProjectState(), parent.getUser(), ref);
|
||||
} catch (AuthException notAllowed) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, notAllowed);
|
||||
} catch (RepositoryNotFoundException noRepo) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(id, noRepo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
|
||||
try {
|
||||
objectId = ObjectId.fromString(id.get());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
|
||||
try (Repository repo = repoManager.openRepository(parent.getNameKey());
|
||||
@ -102,7 +102,7 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
|
||||
}
|
||||
return new CommitResource(parent, commit);
|
||||
} catch (MissingObjectException | IncorrectObjectTypeException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class CreateAccessChange implements RestModifyView<ProjectResource, Proje
|
||||
try {
|
||||
forProject.ref(RefNames.REFS_CONFIG).check(RefPermission.CREATE_CHANGE);
|
||||
} catch (AuthException denied) {
|
||||
throw new AuthException("cannot create change for " + RefNames.REFS_CONFIG);
|
||||
throw new AuthException("cannot create change for " + RefNames.REFS_CONFIG, denied);
|
||||
}
|
||||
}
|
||||
projectCache.checkedGet(rsrc.getNameKey()).checkStatePermitsWrite();
|
||||
|
@ -127,7 +127,7 @@ public class CreateBranch
|
||||
try {
|
||||
object = rw.parseCommit(object);
|
||||
} catch (IncorrectObjectTypeException notCommit) {
|
||||
throw new BadRequestException("\"" + input.revision + "\" not a commit");
|
||||
throw new BadRequestException("\"" + input.revision + "\" not a commit", notCommit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ public class CreateBranch
|
||||
throw err;
|
||||
}
|
||||
} catch (RefUtil.InvalidRevisionException e) {
|
||||
throw new BadRequestException("invalid revision \"" + input.revision + "\"");
|
||||
throw new BadRequestException("invalid revision \"" + input.revision + "\"", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class CreateTag implements RestCollectionCreateView<ProjectResource, TagR
|
||||
}
|
||||
}
|
||||
} catch (InvalidRevisionException e) {
|
||||
throw new BadRequestException("Invalid base revision");
|
||||
throw new BadRequestException("Invalid base revision", e);
|
||||
} catch (GitAPIException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot create tag \"%s\"", ref);
|
||||
throw new IOException(e);
|
||||
|
@ -103,14 +103,14 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
||||
try {
|
||||
info = newDashboardInfo(id.get());
|
||||
} catch (InvalidDashboardId e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
}
|
||||
|
||||
for (ProjectState ps : parent.getProjectState().tree()) {
|
||||
try {
|
||||
return parse(ps, parent.getProjectState(), parent.getUser(), info);
|
||||
} catch (AmbiguousObjectException | ConfigInvalidException | IncorrectObjectTypeException e) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new ResourceNotFoundException(id, e);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
continue;
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
||||
permissionBackend.user(user).project(parent.getNameKey()).ref(ref).check(RefPermission.READ);
|
||||
} catch (AuthException e) {
|
||||
// Don't leak the project's existence
|
||||
throw new ResourceNotFoundException(info.id);
|
||||
throw new ResourceNotFoundException(info.id, e);
|
||||
}
|
||||
if (!Repository.isValidRefName(ref)) {
|
||||
throw new ResourceNotFoundException(info.id);
|
||||
@ -151,7 +151,7 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
||||
BlobBasedConfig cfg = new BlobBasedConfig(null, git, objId);
|
||||
return new DashboardResource(current, user, ref, info.path, cfg, false);
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new ResourceNotFoundException(info.id);
|
||||
throw new ResourceNotFoundException(info.id, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class GetAccess implements RestReadView<ProjectResource> {
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new ResourceNotFoundException(rsrc.getName());
|
||||
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||
}
|
||||
|
||||
// The following implementation must match the ProjectAccessFactory JSON RPC endpoint.
|
||||
|
@ -82,13 +82,13 @@ public class GetHead implements RestReadView<ProjectResource> {
|
||||
.project(rsrc.getNameKey())
|
||||
.check(ProjectPermission.WRITE_CONFIG);
|
||||
} catch (AuthException ae) {
|
||||
throw new AuthException("not allowed to see HEAD");
|
||||
throw new AuthException("not allowed to see HEAD", ae);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new ResourceNotFoundException(Constants.HEAD);
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new ResourceNotFoundException(rsrc.getName());
|
||||
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class GetReflog implements RestReadView<BranchResource> {
|
||||
} catch (UnsupportedOperationException e) {
|
||||
String msg = "reflog not supported on repo " + rsrc.getNameKey().get();
|
||||
logger.atSevere().log(msg);
|
||||
throw new MethodNotAllowedException(msg);
|
||||
throw new MethodNotAllowedException(msg, e);
|
||||
}
|
||||
if (r == null) {
|
||||
throw new ResourceNotFoundException(rsrc.getRef());
|
||||
|
@ -51,7 +51,7 @@ public class GetStatistics implements RestReadView<ProjectResource> {
|
||||
} catch (GitAPIException | JGitInternalException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new ResourceNotFoundException(rsrc.getName());
|
||||
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
}
|
||||
return toBranchInfo(rsrc, ImmutableList.of(r)).get(0);
|
||||
} catch (RepositoryNotFoundException noRepo) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(rsrc.getNameKey().get(), noRepo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
.exactRef(Constants.HEAD, RefNames.REFS_CONFIG, RefNames.REFS_USERS_DEFAULT)
|
||||
.values());
|
||||
} catch (RepositoryNotFoundException noGitRepository) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(rsrc.getNameKey().get(), noGitRepository);
|
||||
}
|
||||
return toBranchInfo(rsrc, refs);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class ListDashboards implements RestReadView<ProjectResource> {
|
||||
}
|
||||
return all;
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(project, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
try {
|
||||
return repoManager.openRepository(project);
|
||||
} catch (RepositoryNotFoundException noGitRepository) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new ResourceNotFoundException(project.get(), noGitRepository);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
uiActions,
|
||||
views);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
throw new ResourceNotFoundException(projectName.get());
|
||||
throw new ResourceNotFoundException(projectName.get(), notFound);
|
||||
} catch (ConfigInvalidException err) {
|
||||
throw new ResourceConflictException("Cannot read project " + projectName, err);
|
||||
} catch (IOException err) {
|
||||
|
@ -92,7 +92,7 @@ public class PutDescription implements RestModifyView<ProjectResource, Descripti
|
||||
? Response.none()
|
||||
: Response.ok(project.getDescription());
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
throw new ResourceNotFoundException(resource.getName());
|
||||
throw new ResourceNotFoundException(resource.getName(), notFound);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("invalid project.config: %s", e.getMessage()));
|
||||
|
@ -130,7 +130,7 @@ public class SetAccess implements RestModifyView<ProjectResource, ProjectAccessI
|
||||
} catch (InvalidNameException e) {
|
||||
throw new BadRequestException(e.toString());
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(rsrc.getName());
|
||||
throw new ResourceConflictException(rsrc.getName(), e);
|
||||
}
|
||||
|
||||
return Response.ok(getAccess.apply(rsrc.getNameKey()));
|
||||
|
@ -89,7 +89,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, SetDashbo
|
||||
new ProjectResource(rsrc.getProjectState(), rsrc.getUser()),
|
||||
IdString.fromUrl(input.id));
|
||||
} catch (ResourceNotFoundException e) {
|
||||
throw new BadRequestException("dashboard " + input.id + " not found");
|
||||
throw new BadRequestException("dashboard " + input.id + " not found", e);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
}
|
||||
@ -125,7 +125,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, SetDashbo
|
||||
}
|
||||
return Response.none();
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
throw new ResourceNotFoundException(rsrc.getProjectState().getProject().getName());
|
||||
throw new ResourceNotFoundException(rsrc.getProjectState().getProject().getName(), notFound);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("invalid project.config: %s", e.getMessage()));
|
||||
|
@ -114,7 +114,7 @@ public class SetHead implements RestModifyView<ProjectResource, HeadInput> {
|
||||
}
|
||||
return Response.ok(ref);
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new ResourceNotFoundException(rsrc.getName());
|
||||
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class SetParent
|
||||
requireNonNull(parent);
|
||||
return parent.get();
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
throw new ResourceNotFoundException(rsrc.getName());
|
||||
throw new ResourceNotFoundException(rsrc.getName(), notFound);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("invalid project.config: %s", e.getMessage()));
|
||||
|
@ -57,7 +57,8 @@ public final class StoredValues {
|
||||
try {
|
||||
return cd.change();
|
||||
} catch (StorageException e) {
|
||||
throw new SystemException("Cannot load change " + cd.getId());
|
||||
throw new SystemException(
|
||||
String.format("Cannot load change %s: %s", cd.getId(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +102,7 @@ public final class StoredValues {
|
||||
try {
|
||||
patchList = plCache.get(plKey, project);
|
||||
} catch (PatchListNotAvailableException e) {
|
||||
throw new SystemException("Cannot create " + plKey);
|
||||
throw new SystemException(String.format("Cannot create %s: %s", plKey, e.getMessage()));
|
||||
}
|
||||
return patchList;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class NoteDbSchemaUpdater {
|
||||
try {
|
||||
schemaCreator.ensureCreated();
|
||||
} catch (IOException | ConfigInvalidException e) {
|
||||
throw new StorageException("Cannot initialize Gerrit site");
|
||||
throw new StorageException("Cannot initialize Gerrit site", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,8 @@ public class RebaseSubmitStrategy extends SubmitStrategy {
|
||||
} catch (MergeConflictException mce) {
|
||||
// Unlike in Cherry-pick case, this should never happen.
|
||||
toMerge.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
|
||||
throw new IllegalStateException("MergeConflictException on message edit must not happen");
|
||||
throw new IllegalStateException(
|
||||
"MergeConflictException on message edit must not happen", mce);
|
||||
} catch (MergeIdenticalTreeException mie) {
|
||||
// this should not happen
|
||||
toMerge.setStatusCode(SKIPPED_IDENTICAL_TREE);
|
||||
|
@ -550,7 +550,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
|
||||
return args.submoduleOp.composeGitlinksCommit(args.destBranch, commit);
|
||||
} catch (SubmoduleException | IOException e) {
|
||||
throw new IntegrationException(
|
||||
"cannot update gitlink for the commit at branch: " + args.destBranch);
|
||||
"cannot update gitlink for the commit at branch: " + args.destBranch, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public final class SocketUtil {
|
||||
try {
|
||||
port = Integer.parseInt(portStr);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("invalid port: " + desc);
|
||||
throw new IllegalArgumentException("invalid port: " + desc, e);
|
||||
}
|
||||
} else {
|
||||
port = defaultPort;
|
||||
|
@ -387,6 +387,10 @@ public abstract class BaseCommand implements Command {
|
||||
return new UnloggedFailure(1, "fatal: " + msg);
|
||||
}
|
||||
|
||||
protected UnloggedFailure die(String msg, Throwable why) {
|
||||
return new UnloggedFailure(1, "fatal: " + msg, why);
|
||||
}
|
||||
|
||||
protected UnloggedFailure die(Throwable why) {
|
||||
return new UnloggedFailure(1, "fatal: " + why.getMessage(), why);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class ChangeArgumentParser {
|
||||
try {
|
||||
changeResource = changesCollection.parse(cId);
|
||||
} catch (RestApiException e) {
|
||||
throw new UnloggedFailure(1, "\"" + id + "\" no such change");
|
||||
throw new UnloggedFailure(1, "\"" + id + "\" no such change", e);
|
||||
}
|
||||
changes.put(cId, changeResource);
|
||||
}
|
||||
|
@ -34,11 +34,10 @@ public class SshKeyCreatorImpl implements SshKeyCreator {
|
||||
SshUtil.parse(key);
|
||||
return key;
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
throw new InvalidSshKeyException();
|
||||
|
||||
throw new InvalidSshKeyException(e);
|
||||
} catch (NoSuchProviderException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot parse SSH key");
|
||||
throw new InvalidSshKeyException();
|
||||
throw new InvalidSshKeyException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ public final class SuExec extends BaseCommand {
|
||||
try {
|
||||
permissionBackend.user(caller).check(GlobalPermission.RUN_AS);
|
||||
} catch (AuthException e) {
|
||||
throw die("suexec not permitted");
|
||||
throw die("suexec not permitted", e);
|
||||
} catch (PermissionBackendException e) {
|
||||
throw die("suexec not available: " + e);
|
||||
throw die("suexec not available", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,9 +104,9 @@ public class LsUserRefs extends SshCommand {
|
||||
throw new Failure(1, "fatal: Error reading refs: '" + projectName, e);
|
||||
}
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw die("'" + projectName + "': not a git archive");
|
||||
throw die("'" + projectName + "': not a git archive", e);
|
||||
} catch (IOException e) {
|
||||
throw die("Error opening: '" + projectName);
|
||||
throw die("Error opening: '" + projectName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class PatchSetParser {
|
||||
try {
|
||||
patchSetId = PatchSet.Id.parse(token);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw error("\"" + token + "\" is not a valid patch set");
|
||||
throw error("\"" + token + "\" is not a valid patch set", e);
|
||||
}
|
||||
ChangeNotes notes = getNotes(projectState, patchSetId.changeId());
|
||||
PatchSet patchSet = psUtil.get(notes, patchSetId);
|
||||
@ -130,7 +130,7 @@ public class PatchSetParser {
|
||||
ChangeNotes notes = changeFinder.findOne(changeId);
|
||||
return notesFactory.create(notes.getProjectName(), changeId);
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw error("\"" + changeId + "\" no such change");
|
||||
throw error("\"" + changeId + "\" no such change", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,4 +153,8 @@ public class PatchSetParser {
|
||||
public static UnloggedFailure error(String msg) {
|
||||
return new UnloggedFailure(1, msg);
|
||||
}
|
||||
|
||||
public static UnloggedFailure error(String msg, Throwable why) {
|
||||
return new UnloggedFailure(1, msg, why);
|
||||
}
|
||||
}
|
||||
|
@ -70,21 +70,21 @@ final class PluginInstallCommand extends PluginAdminSshCommand {
|
||||
try {
|
||||
data = Files.newInputStream(new File(source).toPath());
|
||||
} catch (IOException e) {
|
||||
throw die("cannot read " + source);
|
||||
throw die("cannot read " + source, e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
data = new URL(source).openStream();
|
||||
} catch (MalformedURLException e) {
|
||||
throw die("invalid url " + source);
|
||||
throw die("invalid url " + source, e);
|
||||
} catch (IOException e) {
|
||||
throw die("cannot read " + source);
|
||||
throw die("cannot read " + source, e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
loader.installPluginFromStream(name, data);
|
||||
} catch (IOException e) {
|
||||
throw die("cannot install plugin");
|
||||
throw die("cannot install plugin", e);
|
||||
} catch (PluginInstallException e) {
|
||||
e.printStackTrace(stderr);
|
||||
String msg = String.format("Plugin failed to install. Cause: %s", e.getMessage());
|
||||
|
@ -78,7 +78,7 @@ final class Receive extends AbstractGitCommand {
|
||||
.project(project.getNameKey())
|
||||
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
||||
} catch (AuthException e) {
|
||||
throw new Failure(1, "fatal: receive-pack not permitted on this server");
|
||||
throw new Failure(1, "fatal: receive-pack not permitted on this server", e);
|
||||
} catch (PermissionBackendException e) {
|
||||
throw new Failure(1, "fatal: unable to check permissions " + e);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user