Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: ErrorProne: Enable and fix UnusedException check Update git submodules Also fix a few more instances of UnusedException. Change-Id: Ia9864e78004f17508e13f4bf49d895d470da4942
This commit is contained in:
@@ -235,7 +235,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
|||||||
try {
|
try {
|
||||||
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
|
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException(e.getMessage(), e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
|||||||
.project(req.project)
|
.project(req.project)
|
||||||
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException(e.getMessage(), e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@@ -23,4 +23,8 @@ public class InvalidSshKeyException extends Exception {
|
|||||||
public InvalidSshKeyException() {
|
public InvalidSshKeyException() {
|
||||||
super(MESSAGE);
|
super(MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InvalidSshKeyException(Throwable cause) {
|
||||||
|
super(MESSAGE, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,4 +26,12 @@ public class MethodNotAllowedException extends RestApiException {
|
|||||||
public MethodNotAllowedException(String msg) {
|
public MethodNotAllowedException(String msg) {
|
||||||
super(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) {
|
public NotImplementedException(String message) {
|
||||||
super(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());
|
super("Not found: " + id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResourceNotFoundException(IdString id, Throwable cause) {
|
||||||
|
super("Not found: " + id.get(), cause);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public ResourceNotFoundException caching(CacheControl c) {
|
public ResourceNotFoundException caching(CacheControl c) {
|
||||||
|
@@ -131,7 +131,7 @@ public class HtmlDomUtil {
|
|||||||
try {
|
try {
|
||||||
d = newBuilder().newDocument();
|
d = newBuilder().newDocument();
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
throw new IOException("Cannot clone document");
|
throw new IOException("Cannot clone document", e);
|
||||||
}
|
}
|
||||||
Node n = d.importNode(doc.getDocumentElement(), true);
|
Node n = d.importNode(doc.getDocumentElement(), true);
|
||||||
d.appendChild(n);
|
d.appendChild(n);
|
||||||
|
@@ -195,7 +195,7 @@ class ProjectOAuthFilter implements Filter {
|
|||||||
defaultAuthPlugin = loginProvider.getPluginName();
|
defaultAuthPlugin = loginProvider.getPluginName();
|
||||||
defaultAuthProvider = loginProvider.getExportName();
|
defaultAuthProvider = loginProvider.getExportName();
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
throw new ServletException("No OAuth login provider installed");
|
throw new ServletException("No OAuth login provider installed", e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// multiple providers found => do not pick any
|
// multiple providers found => do not pick any
|
||||||
}
|
}
|
||||||
|
@@ -61,9 +61,11 @@ class PluginServletContext {
|
|||||||
try {
|
try {
|
||||||
handler = API.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
|
handler = API.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
throw new NoSuchMethodError(
|
String msg =
|
||||||
String.format(
|
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);
|
return handler.invoke(this, args);
|
||||||
}
|
}
|
||||||
|
@@ -63,8 +63,9 @@ public class BazelBuild {
|
|||||||
try {
|
try {
|
||||||
status = rebuild.waitFor();
|
status = rebuild.waitFor();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new InterruptedIOException(
|
String msg = "interrupted waiting for: " + Joiner.on(' ').join(proc.command());
|
||||||
"interrupted waiting for: " + Joiner.on(' ').join(proc.command()));
|
logger.atSevere().withCause(e).log(msg);
|
||||||
|
throw new InterruptedIOException(msg);
|
||||||
}
|
}
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
logger.atWarning().log("build failed: %s", new String(out, UTF_8));
|
logger.atWarning().log("build failed: %s", new String(out, UTF_8));
|
||||||
|
@@ -889,7 +889,7 @@ public class RestApiServlet extends HttpServlet {
|
|||||||
try {
|
try {
|
||||||
first = json.peek();
|
first = json.peek();
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
throw new BadRequestException("Expected JSON object");
|
throw new BadRequestException("Expected JSON object", e);
|
||||||
}
|
}
|
||||||
if (first == JsonToken.STRING) {
|
if (first == JsonToken.STRING) {
|
||||||
return parseString(json.nextString(), type);
|
return parseString(json.nextString(), type);
|
||||||
|
@@ -167,7 +167,7 @@ public class QueryBuilder<V> {
|
|||||||
// subclasses of OperatorPredicate.
|
// subclasses of OperatorPredicate.
|
||||||
value = Integer.parseInt(p.getValue());
|
value = Integer.parseInt(p.getValue());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new QueryParseException("not an integer: " + p.getValue());
|
throw new QueryParseException("not an integer: " + p.getValue(), e);
|
||||||
}
|
}
|
||||||
return new TermQuery(intTerm(p.getField().getName(), value));
|
return new TermQuery(intTerm(p.getField().getName(), value));
|
||||||
}
|
}
|
||||||
|
@@ -331,7 +331,7 @@ public class BaseInit extends SiteProgram {
|
|||||||
IoUtil.loadJARs(secureStoreLib);
|
IoUtil.loadJARs(secureStoreLib);
|
||||||
return new SecureStoreInitData(secureStoreLib, secureStores.get(0));
|
return new SecureStoreInitData(secureStoreLib, secureStores.get(0));
|
||||||
} catch (IOException e) {
|
} 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());
|
uri = new URI(s + "://" + uri.getHost() + uri.getPath());
|
||||||
}
|
}
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw die("invalid httpd.listenUrl");
|
throw die("invalid httpd.listenUrl", e);
|
||||||
}
|
}
|
||||||
httpd.set("listenUrl", urlbuf.toString());
|
httpd.set("listenUrl", urlbuf.toString());
|
||||||
gerrit.string("Canonical URL", "canonicalWebUrl", uri.toString());
|
gerrit.string("Canonical URL", "canonicalWebUrl", uri.toString());
|
||||||
|
@@ -318,7 +318,7 @@ public class ApprovalsUtil {
|
|||||||
forChange.check(new LabelPermission.WithValue(name, value));
|
forChange.check(new LabelPermission.WithValue(name, value));
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new AuthException(
|
throw new AuthException(
|
||||||
String.format("applying label \"%s\": %d is restricted", name, value));
|
String.format("applying label \"%s\": %d is restricted", name, value), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -390,7 +390,7 @@ public class AccountManager {
|
|||||||
try {
|
try {
|
||||||
groupsUpdate.updateGroup(groupUuid, groupUpdate);
|
groupsUpdate.updateGroup(groupUuid, groupUpdate);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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.base.Strings;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.extensions.client.AuthType;
|
import com.google.gerrit.extensions.client.AuthType;
|
||||||
@@ -43,6 +44,8 @@ import org.eclipse.jgit.lib.ObjectId;
|
|||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
public abstract class ExternalId implements Serializable {
|
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
|
// If these regular expressions are modified the same modifications should be done to the
|
||||||
// corresponding regular expressions in the
|
// corresponding regular expressions in the
|
||||||
// com.google.gerrit.client.account.UsernameField class.
|
// com.google.gerrit.client.account.UsernameField class.
|
||||||
@@ -391,11 +394,12 @@ public abstract class ExternalId implements Serializable {
|
|||||||
}
|
}
|
||||||
return accountId;
|
return accountId;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw invalidConfig(
|
String msg =
|
||||||
noteId,
|
|
||||||
String.format(
|
String.format(
|
||||||
"Value %s for '%s.%s.%s' is invalid, expected account ID",
|
"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 static com.google.gerrit.util.cli.Localizable.localizable;
|
||||||
|
|
||||||
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
import com.google.gerrit.exceptions.StorageException;
|
||||||
import com.google.gerrit.extensions.client.AuthType;
|
import com.google.gerrit.extensions.client.AuthType;
|
||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
@@ -38,6 +39,8 @@ import org.kohsuke.args4j.spi.Parameters;
|
|||||||
import org.kohsuke.args4j.spi.Setter;
|
import org.kohsuke.args4j.spi.Setter;
|
||||||
|
|
||||||
public class AccountIdHandler extends OptionHandler<Account.Id> {
|
public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||||
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
private final AccountResolver accountResolver;
|
private final AccountResolver accountResolver;
|
||||||
private final AccountManager accountManager;
|
private final AccountManager accountManager;
|
||||||
private final AuthType authType;
|
private final AuthType authType;
|
||||||
@@ -78,11 +81,15 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
|||||||
case OPENID:
|
case OPENID:
|
||||||
case OPENID_SSO:
|
case OPENID_SSO:
|
||||||
default:
|
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) {
|
} 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) {
|
} catch (IOException e) {
|
||||||
throw new CmdLineException(owner, "Failed to load account", e);
|
throw new CmdLineException(owner, "Failed to load account", e);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
@@ -102,7 +109,9 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
|||||||
req.setSkipAuthentication(true);
|
req.setSkipAuthentication(true);
|
||||||
return accountManager.authenticate(req).getAccountId();
|
return accountManager.authenticate(req).getAccountId();
|
||||||
} catch (AccountException e) {
|
} 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;
|
return 1;
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} 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) {
|
} catch (StorageException e) {
|
||||||
throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
|
throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,8 @@ public class PatchSetIdHandler extends OptionHandler<PatchSet.Id> {
|
|||||||
try {
|
try {
|
||||||
id = PatchSet.Id.parse(token);
|
id = PatchSet.Id.parse(token);
|
||||||
} catch (IllegalArgumentException e) {
|
} 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);
|
setter.addValue(id);
|
||||||
|
@@ -89,7 +89,7 @@ public class ProjectHandler extends OptionHandler<ProjectState> {
|
|||||||
permissionBackend.currentUser().project(nameKey).check(permissionToCheck);
|
permissionBackend.currentUser().project(nameKey).check(permissionToCheck);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new CmdLineException(
|
throw new CmdLineException(
|
||||||
owner, localizable(new NoSuchProjectException(nameKey).getMessage()));
|
owner, localizable(new NoSuchProjectException(nameKey, e).getMessage()));
|
||||||
} catch (PermissionBackendException | IOException e) {
|
} catch (PermissionBackendException | IOException e) {
|
||||||
logger.atWarning().withCause(e).log("Cannot load project %s", nameWithoutSuffix);
|
logger.atWarning().withCause(e).log("Cannot load project %s", nameWithoutSuffix);
|
||||||
throw new CmdLineException(
|
throw new CmdLineException(
|
||||||
|
@@ -37,7 +37,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
|||||||
cout.writeInt32NoTag(requireNonNull(object));
|
cout.writeInt32NoTag(requireNonNull(object));
|
||||||
cout.flush();
|
cout.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialize int");
|
throw new IllegalStateException("Failed to serialize int", e);
|
||||||
}
|
}
|
||||||
int n = cout.getTotalBytesWritten();
|
int n = cout.getTotalBytesWritten();
|
||||||
return n == buf.length ? buf : Arrays.copyOfRange(buf, 0, n);
|
return n == buf.length ? buf : Arrays.copyOfRange(buf, 0, n);
|
||||||
@@ -50,7 +50,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
|||||||
try {
|
try {
|
||||||
ret = cin.readRawVarint32();
|
ret = cin.readRawVarint32();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalArgumentException("Failed to deserialize int");
|
throw new IllegalArgumentException("Failed to deserialize int", e);
|
||||||
}
|
}
|
||||||
int n = cin.getTotalBytesRead();
|
int n = cin.getTotalBytesRead();
|
||||||
if (n != in.length) {
|
if (n != in.length) {
|
||||||
|
@@ -50,7 +50,7 @@ public class PureRevert {
|
|||||||
try {
|
try {
|
||||||
claimedOriginalObjectId = ObjectId.fromString(claimedOriginal.get());
|
claimedOriginalObjectId = ObjectId.fromString(claimedOriginal.get());
|
||||||
} catch (InvalidObjectIdException e) {
|
} catch (InvalidObjectIdException e) {
|
||||||
throw new BadRequestException("invalid object ID");
|
throw new BadRequestException("invalid object ID", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pureRevertCache.isPureRevert(
|
return pureRevertCache.isPureRevert(
|
||||||
|
@@ -30,7 +30,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
|
|||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
|
||||||
public class ConfigUtil {
|
public class ConfigUtil {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <T> T[] allValuesOf(T defaultValue) {
|
private static <T> T[] allValuesOf(T defaultValue) {
|
||||||
try {
|
try {
|
||||||
@@ -182,7 +181,7 @@ public class ConfigUtil {
|
|||||||
try {
|
try {
|
||||||
return getTimeUnit(s, defaultValue, wantUnit);
|
return getTimeUnit(s, defaultValue, wantUnit);
|
||||||
} catch (IllegalArgumentException notTime) {
|
} catch (IllegalArgumentException notTime) {
|
||||||
throw notTimeUnit(section, subsection, setting, valueString);
|
throw notTimeUnit(section, subsection, setting, valueString, notTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +249,7 @@ public class ConfigUtil {
|
|||||||
try {
|
try {
|
||||||
return wantUnit.convert(Long.parseLong(digits) * inputMul, inputUnit);
|
return wantUnit.convert(Long.parseLong(digits) * inputMul, inputUnit);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
throw notTimeUnit(valueString);
|
throw notTimeUnit(valueString, nfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,13 +420,21 @@ public class ConfigUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IllegalArgumentException notTimeUnit(
|
private static IllegalArgumentException notTimeUnit(
|
||||||
final String section,
|
String section, String subsection, String setting, String valueString, Throwable why) {
|
||||||
final String subsection,
|
return notTimeUnit(
|
||||||
final String setting,
|
section
|
||||||
final String valueString) {
|
+ (subsection != null ? "." + subsection : "")
|
||||||
return new IllegalArgumentException(
|
+ "."
|
||||||
"Invalid time unit value: "
|
+ setting
|
||||||
+ section
|
+ " = "
|
||||||
|
+ valueString,
|
||||||
|
why);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IllegalArgumentException notTimeUnit(
|
||||||
|
String section, String subsection, String setting, String valueString) {
|
||||||
|
return notTimeUnit(
|
||||||
|
section
|
||||||
+ (subsection != null ? "." + subsection : "")
|
+ (subsection != null ? "." + subsection : "")
|
||||||
+ "."
|
+ "."
|
||||||
+ setting
|
+ setting
|
||||||
@@ -439,5 +446,9 @@ public class ConfigUtil {
|
|||||||
return new IllegalArgumentException("Invalid time unit value: " + val);
|
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() {}
|
private ConfigUtil() {}
|
||||||
}
|
}
|
||||||
|
@@ -748,6 +748,7 @@ public class MergeUtil {
|
|||||||
try {
|
try {
|
||||||
failed(rw, mergeTip, n, getCommitMergeStatus(e.getReason()));
|
failed(rw, mergeTip, n, getCommitMergeStatus(e.getReason()));
|
||||||
} catch (IOException e2) {
|
} 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);
|
throw new IntegrationException("Cannot merge " + n.name(), e);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@@ -163,7 +163,7 @@ public class PureRevertCache {
|
|||||||
try {
|
try {
|
||||||
claimedOriginalCommit = rw.parseCommit(original);
|
claimedOriginalCommit = rw.parseCommit(original);
|
||||||
} catch (InvalidObjectIdException | MissingObjectException e) {
|
} catch (InvalidObjectIdException | MissingObjectException e) {
|
||||||
throw new BadRequestException("invalid object ID");
|
throw new BadRequestException("invalid object ID", e);
|
||||||
}
|
}
|
||||||
if (claimedOriginalCommit.getParentCount() == 0) {
|
if (claimedOriginalCommit.getParentCount() == 0) {
|
||||||
throw new BadRequestException("can't check against initial commit");
|
throw new BadRequestException("can't check against initial commit");
|
||||||
|
@@ -27,6 +27,11 @@ public class CommitValidationException extends ValidationException {
|
|||||||
this.messages = ImmutableList.of(message);
|
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) {
|
public CommitValidationException(String reason, List<CommitValidationMessage> messages) {
|
||||||
super(reason);
|
super(reason);
|
||||||
this.messages = ImmutableList.copyOf(messages);
|
this.messages = ImmutableList.copyOf(messages);
|
||||||
|
@@ -467,7 +467,7 @@ public class CommitValidators {
|
|||||||
perm.check(RefPermission.MERGE);
|
perm.check(RefPermission.MERGE);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} catch (AuthException e) {
|
} 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) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot check MERGE");
|
logger.atSevere().withCause(e).log("cannot check MERGE");
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -564,7 +564,7 @@ public class CommitValidators {
|
|||||||
perm.check(RefPermission.FORGE_COMMITTER);
|
perm.check(RefPermission.FORGE_COMMITTER);
|
||||||
} catch (AuthException denied) {
|
} catch (AuthException denied) {
|
||||||
throw new CommitValidationException(
|
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) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -599,7 +599,7 @@ public class CommitValidators {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new CommitValidationException(
|
throw new CommitValidationException(
|
||||||
"invalid author", invalidEmail("author", author, user, urlFormatter));
|
"invalid author", invalidEmail("author", author, user, urlFormatter), e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot check FORGE_AUTHOR");
|
logger.atSevere().withCause(e).log("cannot check FORGE_AUTHOR");
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -632,7 +632,7 @@ public class CommitValidators {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new CommitValidationException(
|
throw new CommitValidationException(
|
||||||
"invalid committer", invalidEmail("committer", committer, user, urlFormatter));
|
"invalid committer", invalidEmail("committer", committer, user, urlFormatter), e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
logger.atSevere().withCause(e).log("cannot check FORGE_COMMITTER");
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
@@ -671,7 +671,8 @@ public class CommitValidators {
|
|||||||
"pushing merge commit %s by %s requires '%s' permission",
|
"pushing merge commit %s by %s requires '%s' permission",
|
||||||
receiveEvent.commit.getId(),
|
receiveEvent.commit.getId(),
|
||||||
gerritIdent.getEmailAddress(),
|
gerritIdent.getEmailAddress(),
|
||||||
RefPermission.FORGE_SERVER.name()));
|
RefPermission.FORGE_SERVER.name()),
|
||||||
|
denied);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot check FORGE_SERVER");
|
logger.atSevere().withCause(e).log("cannot check FORGE_SERVER");
|
||||||
throw new CommitValidationException("internal auth error");
|
throw new CommitValidationException("internal auth error");
|
||||||
|
@@ -28,4 +28,8 @@ public class MergeValidationException extends ValidationException {
|
|||||||
public MergeValidationException(String msg) {
|
public MergeValidationException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MergeValidationException(String msg, Throwable why) {
|
||||||
|
super(msg, why);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -178,7 +178,7 @@ public class MergeValidators {
|
|||||||
try {
|
try {
|
||||||
permissionBackend.user(caller).check(GlobalPermission.ADMINISTRATE_SERVER);
|
permissionBackend.user(caller).check(GlobalPermission.ADMINISTRATE_SERVER);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new MergeValidationException(SET_BY_ADMIN);
|
throw new MergeValidationException(SET_BY_ADMIN, e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atWarning().withCause(e).log("Cannot check ADMINISTRATE_SERVER");
|
logger.atWarning().withCause(e).log("Cannot check ADMINISTRATE_SERVER");
|
||||||
throw new MergeValidationException("validation unavailable");
|
throw new MergeValidationException("validation unavailable");
|
||||||
@@ -190,7 +190,7 @@ public class MergeValidators {
|
|||||||
.project(destProject.getNameKey())
|
.project(destProject.getNameKey())
|
||||||
.check(ProjectPermission.WRITE_CONFIG);
|
.check(ProjectPermission.WRITE_CONFIG);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new MergeValidationException(SET_BY_OWNER);
|
throw new MergeValidationException(SET_BY_OWNER, e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
logger.atWarning().withCause(e).log("Cannot check WRITE_CONFIG");
|
logger.atWarning().withCause(e).log("Cannot check WRITE_CONFIG");
|
||||||
throw new MergeValidationException("validation unavailable");
|
throw new MergeValidationException("validation unavailable");
|
||||||
@@ -231,7 +231,7 @@ public class MergeValidators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ConfigInvalidException | IOException e) {
|
} catch (ConfigInvalidException | IOException e) {
|
||||||
throw new MergeValidationException(INVALID_CONFIG);
|
throw new MergeValidationException(INVALID_CONFIG, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -132,7 +132,7 @@ public class RefOperationValidators {
|
|||||||
try {
|
try {
|
||||||
perm.check(GlobalPermission.ACCESS_DATABASE);
|
perm.check(GlobalPermission.ACCESS_DATABASE);
|
||||||
} catch (AuthException | PermissionBackendException e) {
|
} 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) {
|
if (Account.Id.fromRef(refEvent.command.getRefName()) == null) {
|
||||||
throw new ValidationException(
|
throw new ValidationException(
|
||||||
@@ -143,7 +143,7 @@ public class RefOperationValidators {
|
|||||||
try {
|
try {
|
||||||
perm.check(GlobalPermission.ACCESS_DATABASE);
|
perm.check(GlobalPermission.ACCESS_DATABASE);
|
||||||
} catch (AuthException | PermissionBackendException e) {
|
} catch (AuthException | PermissionBackendException e) {
|
||||||
throw new ValidationException("Not allowed to delete user branch.");
|
throw new ValidationException("Not allowed to delete user branch.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -296,7 +296,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
try {
|
try {
|
||||||
ps = args.patchSetUtil.get(changeData.notes(), new PatchSet.Id(change.getId(), patchSetId));
|
ps = args.patchSetUtil.get(changeData.notes(), new PatchSet.Id(change.getId(), patchSetId));
|
||||||
} catch (StorageException e) {
|
} catch (StorageException e) {
|
||||||
throw new PatchListNotAvailableException("Failed to get patchSet");
|
throw new PatchListNotAvailableException("Failed to get patchSet", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return args.patchListCache.get(change, ps);
|
return args.patchListCache.get(change, ps);
|
||||||
|
@@ -912,7 +912,9 @@ class ChangeNotesParser {
|
|||||||
try {
|
try {
|
||||||
adr = Address.parse(line);
|
adr = Address.parse(line);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw invalidFooter(state.getByEmailFooterKey(), line);
|
ConfigInvalidException cie = invalidFooter(state.getByEmailFooterKey(), line);
|
||||||
|
cie.initCause(e);
|
||||||
|
throw cie;
|
||||||
}
|
}
|
||||||
if (!reviewersByEmail.containsRow(adr)) {
|
if (!reviewersByEmail.containsRow(adr)) {
|
||||||
reviewersByEmail.put(adr, state, ts);
|
reviewersByEmail.put(adr, state, ts);
|
||||||
|
@@ -199,7 +199,7 @@ public class PatchScriptFactory implements Callable<PatchScript> {
|
|||||||
try {
|
try {
|
||||||
permissionBackend.currentUser().change(notes).check(ChangePermission.READ);
|
permissionBackend.currentUser().change(notes).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new NoSuchChangeException(changeId);
|
throw new NoSuchChangeException(changeId, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,9 +125,10 @@ public class ProjectCreator {
|
|||||||
+ nameKey.get()
|
+ nameKey.get()
|
||||||
+ " because the name is already occupied by another project."
|
+ " because the name is already occupied by another project."
|
||||||
+ " The other project has the same name, only spelled in a"
|
+ " The other project has the same name, only spelled in a"
|
||||||
+ " different case.");
|
+ " different case.",
|
||||||
|
e);
|
||||||
} catch (RepositoryNotFoundException badName) {
|
} catch (RepositoryNotFoundException badName) {
|
||||||
throw new BadRequestException("invalid project name: " + nameKey);
|
throw new BadRequestException("invalid project name: " + nameKey, badName);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
String msg = "Cannot create " + nameKey;
|
String msg = "Cannot create " + nameKey;
|
||||||
logger.atSevere().withCause(e).log(msg);
|
logger.atSevere().withCause(e).log(msg);
|
||||||
|
@@ -55,7 +55,7 @@ public class RefUtil {
|
|||||||
"Cannot resolve \"%s\" in project \"%s\"", baseRevision, projectName.get());
|
"Cannot resolve \"%s\" in project \"%s\"", baseRevision, projectName.get());
|
||||||
throw new InvalidRevisionException(baseRevision);
|
throw new InvalidRevisionException(baseRevision);
|
||||||
} catch (RevisionSyntaxException err) {
|
} catch (RevisionSyntaxException err) {
|
||||||
throw new InvalidRevisionException(baseRevision);
|
throw new InvalidRevisionException(baseRevision, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class RefUtil {
|
|||||||
try {
|
try {
|
||||||
rw.markStart(rw.parseCommit(revid));
|
rw.markStart(rw.parseCommit(revid));
|
||||||
} catch (IncorrectObjectTypeException err) {
|
} catch (IncorrectObjectTypeException err) {
|
||||||
throw new InvalidRevisionException(revid.name());
|
throw new InvalidRevisionException(revid.name(), err);
|
||||||
}
|
}
|
||||||
RefDatabase refDb = repo.getRefDatabase();
|
RefDatabase refDb = repo.getRefDatabase();
|
||||||
Iterable<Ref> refs =
|
Iterable<Ref> refs =
|
||||||
@@ -86,7 +86,7 @@ public class RefUtil {
|
|||||||
rw.checkConnectivity();
|
rw.checkConnectivity();
|
||||||
return rw;
|
return rw;
|
||||||
} catch (IncorrectObjectTypeException | MissingObjectException err) {
|
} catch (IncorrectObjectTypeException | MissingObjectException err) {
|
||||||
throw new InvalidRevisionException(revid.name());
|
throw new InvalidRevisionException(revid.name(), err);
|
||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
logger.atSevere().withCause(err).log(
|
logger.atSevere().withCause(err).log(
|
||||||
"Repository \"%s\" may be corrupt; suggest running git fsck", repo.getDirectory());
|
"Repository \"%s\" may be corrupt; suggest running git fsck", repo.getDirectory());
|
||||||
@@ -128,5 +128,9 @@ public class RefUtil {
|
|||||||
InvalidRevisionException(@Nullable String invalidRevision) {
|
InvalidRevisionException(@Nullable String invalidRevision) {
|
||||||
super(MESSAGE + ": " + 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 {
|
try {
|
||||||
args.permissionBackend.user(args.getUser()).change(changeNotes).check(ChangePermission.READ);
|
args.permissionBackend.user(args.getUser()).change(changeNotes).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} 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);
|
return AccountPredicates.cansee(args, changeNotes);
|
||||||
|
@@ -75,7 +75,7 @@ public class ProjectQueryBuilder extends QueryBuilder<ProjectData, ProjectQueryB
|
|||||||
try {
|
try {
|
||||||
parsedState = ProjectState.valueOf(state.replace('-', '_').toUpperCase());
|
parsedState = ProjectState.valueOf(state.replace('-', '_').toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} 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) {
|
if (parsedState == ProjectState.HIDDEN) {
|
||||||
throw error("state operator must be either 'active' or 'read-only'");
|
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);
|
permissionBackend.absentUser(target.getAccountId()).check(perm);
|
||||||
return new AccountResource.Capability(target, globalOrPluginPermissionName(perm));
|
return new AccountResource.Capability(target, globalOrPluginPermissionName(perm));
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -156,7 +156,7 @@ public class CreateAccount
|
|||||||
try {
|
try {
|
||||||
addGroupMember(groupUuid, accountId);
|
addGroupMember(groupUuid, accountId);
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new UnprocessableEntityException(String.format("Group %s not found", groupUuid));
|
throw new UnprocessableEntityException(String.format("Group %s not found", groupUuid), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -95,7 +95,7 @@ public class PutAgreement implements RestModifyView<AccountResource, AgreementIn
|
|||||||
try {
|
try {
|
||||||
addMembers.addMembers(uuid, ImmutableSet.of(accountState.getAccount().getId()));
|
addMembers.addMembers(uuid, ImmutableSet.of(accountState.getAccount().getId()));
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new ResourceConflictException("autoverify group not found");
|
throw new ResourceConflictException("autoverify group not found", e);
|
||||||
}
|
}
|
||||||
agreementSignup.fire(accountState, agreementName);
|
agreementSignup.fire(accountState, agreementName);
|
||||||
|
|
||||||
|
@@ -115,7 +115,7 @@ public class PutUsername implements RestModifyView<AccountResource, UsernameInpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, someone else has this identity.
|
// Otherwise, someone else has this identity.
|
||||||
throw new ResourceConflictException("username already used");
|
throw new ResourceConflictException("username already used", dupeErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sshKeyCache.evict(input.username);
|
sshKeyCache.evict(input.username);
|
||||||
|
@@ -70,7 +70,7 @@ public class SshKeys implements ChildCollection<AccountResource, AccountResource
|
|||||||
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
|
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
// If lacking MODIFY_ACCOUNT claim the resource does not exist.
|
// If lacking MODIFY_ACCOUNT claim the resource does not exist.
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parse(rsrc.getUser(), id);
|
return parse(rsrc.getUser(), id);
|
||||||
@@ -86,7 +86,7 @@ public class SshKeys implements ChildCollection<AccountResource, AccountResource
|
|||||||
}
|
}
|
||||||
return new AccountResource.SshKey(user, sshKey);
|
return new AccountResource.SshKey(user, sshKey);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,10 +123,10 @@ public class StarredChanges
|
|||||||
try {
|
try {
|
||||||
change = changes.parse(TopLevelResource.INSTANCE, id);
|
change = changes.parse(TopLevelResource.INSTANCE, id);
|
||||||
} catch (ResourceNotFoundException e) {
|
} 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) {
|
} catch (StorageException | PermissionBackendException | IOException e) {
|
||||||
logger.atSevere().withCause(e).log("cannot resolve change");
|
logger.atSevere().withCause(e).log("cannot resolve change");
|
||||||
throw new UnprocessableEntityException("internal server error");
|
throw new UnprocessableEntityException("internal server error", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -286,7 +286,8 @@ public class CherryPickChange {
|
|||||||
try {
|
try {
|
||||||
baseObjectId = ObjectId.fromString(base);
|
baseObjectId = ObjectId.fromString(base);
|
||||||
} catch (InvalidObjectIdException e) {
|
} 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;
|
RevCommit baseCommit;
|
||||||
|
@@ -254,7 +254,7 @@ public class CreateChange
|
|||||||
try {
|
try {
|
||||||
permissionBackend.currentUser().project(project).ref(refName).check(RefPermission.READ);
|
permissionBackend.currentUser().project(project).ref(refName).check(RefPermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new ResourceNotFoundException(String.format("ref %s not found", refName));
|
throw new ResourceNotFoundException(String.format("ref %s not found", refName), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionBackend
|
permissionBackend
|
||||||
@@ -332,7 +332,7 @@ public class CreateChange
|
|||||||
try {
|
try {
|
||||||
permissionBackend.currentUser().change(change).check(ChangePermission.READ);
|
permissionBackend.currentUser().change(change).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new UnprocessableEntityException("Read not permitted for " + baseChange);
|
throw new UnprocessableEntityException("Read not permitted for " + baseChange, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return change;
|
return change;
|
||||||
@@ -360,14 +360,15 @@ public class CreateChange
|
|||||||
parentCommit = ObjectId.fromString(baseCommit);
|
parentCommit = ObjectId.fromString(baseCommit);
|
||||||
} catch (InvalidObjectIdException e) {
|
} catch (InvalidObjectIdException e) {
|
||||||
throw new UnprocessableEntityException(
|
throw new UnprocessableEntityException(
|
||||||
String.format("Base %s doesn't represent a valid SHA-1", baseCommit));
|
String.format("Base %s doesn't represent a valid SHA-1", baseCommit), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
RevCommit parentRevCommit;
|
RevCommit parentRevCommit;
|
||||||
try {
|
try {
|
||||||
parentRevCommit = revWalk.parseCommit(parentCommit);
|
parentRevCommit = revWalk.parseCommit(parentCommit);
|
||||||
} catch (MissingObjectException e) {
|
} catch (MissingObjectException e) {
|
||||||
throw new UnprocessableEntityException(String.format("Base %s doesn't exist", baseCommit));
|
throw new UnprocessableEntityException(
|
||||||
|
String.format("Base %s doesn't exist", baseCommit), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destRef == null) {
|
if (destRef == null) {
|
||||||
|
@@ -207,7 +207,7 @@ public class CreateMergePatchSet
|
|||||||
try {
|
try {
|
||||||
permissionBackend.currentUser().change(change).check(ChangePermission.READ);
|
permissionBackend.currentUser().change(change).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new UnprocessableEntityException("Read not permitted for " + baseChange);
|
throw new UnprocessableEntityException("Read not permitted for " + baseChange, e);
|
||||||
}
|
}
|
||||||
return psUtil.current(change);
|
return psUtil.current(change);
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.PatchScript;
|
import com.google.gerrit.common.data.PatchScript;
|
||||||
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
|
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
|
||||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
||||||
@@ -73,6 +74,8 @@ import org.kohsuke.args4j.spi.Parameters;
|
|||||||
import org.kohsuke.args4j.spi.Setter;
|
import org.kohsuke.args4j.spi.Setter;
|
||||||
|
|
||||||
public class GetDiff implements RestReadView<FileResource> {
|
public class GetDiff implements RestReadView<FileResource> {
|
||||||
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
private static final ImmutableMap<Patch.ChangeType, ChangeType> CHANGE_TYPE =
|
private static final ImmutableMap<Patch.ChangeType, ChangeType> CHANGE_TYPE =
|
||||||
Maps.immutableEnumMap(
|
Maps.immutableEnumMap(
|
||||||
new ImmutableMap.Builder<Patch.ChangeType, ChangeType>()
|
new ImmutableMap.Builder<Patch.ChangeType, ChangeType>()
|
||||||
@@ -433,6 +436,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
logger.atFine().withCause(e).log("invalid numeric value");
|
||||||
throw new CmdLineException(
|
throw new CmdLineException(
|
||||||
owner,
|
owner,
|
||||||
localizable("\"%s\" is not a valid value for \"%s\""),
|
localizable("\"%s\" is not a valid value for \"%s\""),
|
||||||
|
@@ -469,7 +469,8 @@ public class PostReview
|
|||||||
throw new AuthException(
|
throw new AuthException(
|
||||||
String.format(
|
String.format(
|
||||||
"not permitted to modify label \"%s\" on behalf of \"%s\"",
|
"not permitted to modify label \"%s\" on behalf of \"%s\"",
|
||||||
type.getName(), in.onBehalfOf));
|
type.getName(), in.onBehalfOf),
|
||||||
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,7 +484,7 @@ public class PostReview
|
|||||||
permissionBackend.user(reviewer).change(rev.getNotes()).check(ChangePermission.READ);
|
permissionBackend.user(reviewer).change(rev.getNotes()).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new UnprocessableEntityException(
|
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(
|
return new RevisionResource(
|
||||||
@@ -526,7 +527,7 @@ public class PostReview
|
|||||||
perm.check(new LabelPermission.WithValue(lt, val));
|
perm.check(new LabelPermission.WithValue(lt, val));
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new AuthException(
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -173,7 +173,7 @@ public class PreviewSubmit implements RestReadView<RevisionResource> {
|
|||||||
archiveFormat.putEntry(aos, path, bos.toByteArray());
|
archiveFormat.putEntry(aos, path, bos.toByteArray());
|
||||||
}
|
}
|
||||||
} catch (LimitExceededException e) {
|
} 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) {
|
} catch (NoSuchProjectException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ public class PutAssignee extends RetryingRestModifyView<ChangeResource, Assignee
|
|||||||
.change(rsrc.getNotes())
|
.change(rsrc.getNotes())
|
||||||
.check(ChangePermission.READ);
|
.check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} 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 =
|
try (BatchUpdate bu =
|
||||||
|
@@ -119,7 +119,7 @@ public class QueryChanges implements RestReadView<TopLevelResource>, DynamicOpti
|
|||||||
try {
|
try {
|
||||||
out = query();
|
out = query();
|
||||||
} catch (QueryRequiresAuthException e) {
|
} 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) {
|
} catch (QueryParseException e) {
|
||||||
logger.atFine().withCause(e).log("Reject change query with 400 Bad Request: %s", queries);
|
logger.atFine().withCause(e).log("Reject change query with 400 Bad Request: %s", queries);
|
||||||
throw new BadRequestException(e.getMessage(), e);
|
throw new BadRequestException(e.getMessage(), e);
|
||||||
|
@@ -214,7 +214,7 @@ public class Submit
|
|||||||
try {
|
try {
|
||||||
change = changeNotesFactory.createChecked(change.getProject(), change.getId()).getChange();
|
change = changeNotesFactory.createChecked(change.getProject(), change.getId()).getChange();
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
throw new ResourceConflictException("change is deleted");
|
throw new ResourceConflictException("change is deleted", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change.isMerged()) {
|
if (change.isMerged()) {
|
||||||
@@ -448,7 +448,7 @@ public class Submit
|
|||||||
permissionBackend.user(submitter).change(rsrc.getNotes()).check(ChangePermission.READ);
|
permissionBackend.user(submitter).change(rsrc.getNotes()).check(ChangePermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new UnprocessableEntityException(
|
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;
|
return submitter;
|
||||||
}
|
}
|
||||||
|
@@ -76,7 +76,7 @@ public class ConfirmEmail implements RestModifyView<ConfigResource, Input> {
|
|||||||
}
|
}
|
||||||
throw new UnprocessableEntityException("invalid token");
|
throw new UnprocessableEntityException("invalid token");
|
||||||
} catch (EmailTokenVerifier.InvalidTokenException e) {
|
} catch (EmailTokenVerifier.InvalidTokenException e) {
|
||||||
throw new UnprocessableEntityException("invalid token");
|
throw new UnprocessableEntityException("invalid token", e);
|
||||||
} catch (AccountException e) {
|
} catch (AccountException e) {
|
||||||
throw new UnprocessableEntityException(e.getMessage());
|
throw new UnprocessableEntityException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ public class TasksCollection implements ChildCollection<ConfigResource, TaskReso
|
|||||||
try {
|
try {
|
||||||
taskId = (int) Long.parseLong(id.get(), 16);
|
taskId = (int) Long.parseLong(id.get(), 16);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task<?> task = workQueue.getTask(taskId);
|
Task<?> task = workQueue.getTask(taskId);
|
||||||
|
@@ -137,7 +137,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
try {
|
try {
|
||||||
addMembers(groupUuid, newMemberIds);
|
addMembers(groupUuid, newMemberIds);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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 toAccountInfoList(newMemberIds);
|
return toAccountInfoList(newMemberIds);
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
}
|
}
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
} catch (UnprocessableEntityException e) {
|
} catch (UnprocessableEntityException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
|
|||||||
try {
|
try {
|
||||||
addSubgroups(groupUuid, subgroupUuids);
|
addSubgroups(groupUuid, subgroupUuids);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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 result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
|
|||||||
}
|
}
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
} catch (UnprocessableEntityException e) {
|
} catch (UnprocessableEntityException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -219,7 +219,7 @@ public class CreateGroup
|
|||||||
return groupsUpdateProvider.get().createGroup(groupCreation, groupUpdateBuilder.build());
|
return groupsUpdateProvider.get().createGroup(groupCreation, groupUpdateBuilder.build());
|
||||||
} catch (DuplicateKeyException e) {
|
} catch (DuplicateKeyException e) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
"group '" + createGroupArgs.getGroupName() + "' already exists");
|
"group '" + createGroupArgs.getGroupName() + "' already exists", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
try {
|
try {
|
||||||
removeGroupMembers(groupUuid, membersToRemove);
|
removeGroupMembers(groupUuid, membersToRemove);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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();
|
return Response.none();
|
||||||
|
@@ -77,7 +77,7 @@ public class DeleteSubgroups implements RestModifyView<GroupResource, Input> {
|
|||||||
try {
|
try {
|
||||||
removeSubgroups(groupUuid, subgroupsToRemove);
|
removeSubgroups(groupUuid, subgroupsToRemove);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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();
|
return Response.none();
|
||||||
|
@@ -46,7 +46,7 @@ public class GetOwner implements RestReadView<GroupResource> {
|
|||||||
GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
|
GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
|
||||||
return json.format(c.getGroup());
|
return json.format(c.getGroup());
|
||||||
} catch (NoSuchGroupException e) {
|
} 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 {
|
try {
|
||||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,9 +78,9 @@ public class PutName implements RestModifyView<GroupResource, NameInput> {
|
|||||||
try {
|
try {
|
||||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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) {
|
} catch (DuplicateKeyException e) {
|
||||||
throw new ResourceConflictException("group with name " + newName + " already exists");
|
throw new ResourceConflictException("group with name " + newName + " already exists", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ public class PutOptions implements RestModifyView<GroupResource, GroupOptionsInf
|
|||||||
try {
|
try {
|
||||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
|
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ public class PutOwner implements RestModifyView<GroupResource, OwnerInput> {
|
|||||||
try {
|
try {
|
||||||
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate);
|
||||||
} catch (NoSuchGroupException e) {
|
} 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 json.format(owner);
|
return json.format(owner);
|
||||||
|
@@ -82,9 +82,9 @@ public class BranchesCollection implements ChildCollection<ProjectResource, Bran
|
|||||||
.check(RefPermission.READ);
|
.check(RefPermission.READ);
|
||||||
return new BranchResource(parent.getProjectState(), parent.getUser(), ref);
|
return new BranchResource(parent.getProjectState(), parent.getUser(), ref);
|
||||||
} catch (AuthException notAllowed) {
|
} catch (AuthException notAllowed) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, notAllowed);
|
||||||
} catch (RepositoryNotFoundException noRepo) {
|
} catch (RepositoryNotFoundException noRepo) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(id, noRepo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
|
|||||||
try {
|
try {
|
||||||
objectId = ObjectId.fromString(id.get());
|
objectId = ObjectId.fromString(id.get());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Repository repo = repoManager.openRepository(parent.getNameKey());
|
try (Repository repo = repoManager.openRepository(parent.getNameKey());
|
||||||
@@ -95,7 +95,7 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
|
|||||||
}
|
}
|
||||||
return new CommitResource(parent, commit);
|
return new CommitResource(parent, commit);
|
||||||
} catch (MissingObjectException | IncorrectObjectTypeException e) {
|
} 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 {
|
try {
|
||||||
forProject.ref(RefNames.REFS_CONFIG).check(RefPermission.CREATE_CHANGE);
|
forProject.ref(RefNames.REFS_CONFIG).check(RefPermission.CREATE_CHANGE);
|
||||||
} catch (AuthException denied) {
|
} 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();
|
projectCache.checkedGet(rsrc.getNameKey()).checkStatePermitsWrite();
|
||||||
|
@@ -125,7 +125,7 @@ public class CreateBranch
|
|||||||
try {
|
try {
|
||||||
object = rw.parseCommit(object);
|
object = rw.parseCommit(object);
|
||||||
} catch (IncorrectObjectTypeException notCommit) {
|
} catch (IncorrectObjectTypeException notCommit) {
|
||||||
throw new BadRequestException("\"" + input.revision + "\" not a commit");
|
throw new BadRequestException("\"" + input.revision + "\" not a commit", notCommit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ public class CreateBranch
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
} catch (RefUtil.InvalidRevisionException e) {
|
} catch (RefUtil.InvalidRevisionException e) {
|
||||||
throw new BadRequestException("invalid revision \"" + input.revision + "\"");
|
throw new BadRequestException("invalid revision \"" + input.revision + "\"", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -147,7 +147,7 @@ public class CreateTag implements RestCollectionCreateView<ProjectResource, TagR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InvalidRevisionException e) {
|
} catch (InvalidRevisionException e) {
|
||||||
throw new BadRequestException("Invalid base revision");
|
throw new BadRequestException("Invalid base revision", e);
|
||||||
} catch (GitAPIException e) {
|
} catch (GitAPIException e) {
|
||||||
logger.atSevere().withCause(e).log("Cannot create tag \"%s\"", ref);
|
logger.atSevere().withCause(e).log("Cannot create tag \"%s\"", ref);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
@@ -103,14 +103,14 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
|||||||
try {
|
try {
|
||||||
info = newDashboardInfo(id.get());
|
info = newDashboardInfo(id.get());
|
||||||
} catch (InvalidDashboardId e) {
|
} catch (InvalidDashboardId e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ProjectState ps : parent.getProjectState().tree()) {
|
for (ProjectState ps : parent.getProjectState().tree()) {
|
||||||
try {
|
try {
|
||||||
return parse(ps, parent.getProjectState(), parent.getUser(), info);
|
return parse(ps, parent.getProjectState(), parent.getUser(), info);
|
||||||
} catch (AmbiguousObjectException | ConfigInvalidException | IncorrectObjectTypeException e) {
|
} catch (AmbiguousObjectException | ConfigInvalidException | IncorrectObjectTypeException e) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id, e);
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
|||||||
permissionBackend.user(user).project(parent.getNameKey()).ref(ref).check(RefPermission.READ);
|
permissionBackend.user(user).project(parent.getNameKey()).ref(ref).check(RefPermission.READ);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
// Don't leak the project's existence
|
// Don't leak the project's existence
|
||||||
throw new ResourceNotFoundException(info.id);
|
throw new ResourceNotFoundException(info.id, e);
|
||||||
}
|
}
|
||||||
if (!Repository.isValidRefName(ref)) {
|
if (!Repository.isValidRefName(ref)) {
|
||||||
throw new ResourceNotFoundException(info.id);
|
throw new ResourceNotFoundException(info.id);
|
||||||
@@ -151,7 +151,7 @@ public class DashboardsCollection implements ChildCollection<ProjectResource, Da
|
|||||||
BlobBasedConfig cfg = new BlobBasedConfig(null, git, objId);
|
BlobBasedConfig cfg = new BlobBasedConfig(null, git, objId);
|
||||||
return new DashboardResource(current, user, ref, info.path, cfg, false);
|
return new DashboardResource(current, user, ref, info.path, cfg, false);
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new ResourceNotFoundException(info.id);
|
throw new ResourceNotFoundException(info.id, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,7 +166,7 @@ public class GetAccess implements RestReadView<ProjectResource> {
|
|||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(e.getMessage());
|
throw new ResourceConflictException(e.getMessage());
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new ResourceNotFoundException(rsrc.getName());
|
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following implementation must match the ProjectAccessFactory JSON RPC endpoint.
|
// The following implementation must match the ProjectAccessFactory JSON RPC endpoint.
|
||||||
|
@@ -81,13 +81,13 @@ public class GetHead implements RestReadView<ProjectResource> {
|
|||||||
.project(rsrc.getNameKey())
|
.project(rsrc.getNameKey())
|
||||||
.check(ProjectPermission.WRITE_CONFIG);
|
.check(ProjectPermission.WRITE_CONFIG);
|
||||||
} catch (AuthException ae) {
|
} 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);
|
throw new ResourceNotFoundException(Constants.HEAD);
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new ResourceNotFoundException(rsrc.getName());
|
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -103,7 +103,7 @@ public class GetReflog implements RestReadView<BranchResource> {
|
|||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
String msg = "reflog not supported on repo " + rsrc.getNameKey().get();
|
String msg = "reflog not supported on repo " + rsrc.getNameKey().get();
|
||||||
logger.atSevere().log(msg);
|
logger.atSevere().log(msg);
|
||||||
throw new MethodNotAllowedException(msg);
|
throw new MethodNotAllowedException(msg, e);
|
||||||
}
|
}
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
throw new ResourceNotFoundException(rsrc.getRef());
|
throw new ResourceNotFoundException(rsrc.getRef());
|
||||||
|
@@ -50,7 +50,7 @@ public class GetStatistics implements RestReadView<ProjectResource> {
|
|||||||
} catch (GitAPIException | JGitInternalException e) {
|
} catch (GitAPIException | JGitInternalException e) {
|
||||||
throw new ResourceConflictException(e.getMessage());
|
throw new ResourceConflictException(e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ResourceNotFoundException(rsrc.getName());
|
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -147,7 +147,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
|||||||
}
|
}
|
||||||
return toBranchInfo(rsrc, ImmutableList.of(r)).get(0);
|
return toBranchInfo(rsrc, ImmutableList.of(r)).get(0);
|
||||||
} catch (RepositoryNotFoundException noRepo) {
|
} catch (RepositoryNotFoundException noRepo) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(rsrc.getNameKey().get(), noRepo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
|||||||
.exactRef(Constants.HEAD, RefNames.REFS_CONFIG, RefNames.REFS_USERS_DEFAULT)
|
.exactRef(Constants.HEAD, RefNames.REFS_CONFIG, RefNames.REFS_USERS_DEFAULT)
|
||||||
.values());
|
.values());
|
||||||
} catch (RepositoryNotFoundException noGitRepository) {
|
} catch (RepositoryNotFoundException noGitRepository) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(rsrc.getNameKey().get(), noGitRepository);
|
||||||
}
|
}
|
||||||
return toBranchInfo(rsrc, refs);
|
return toBranchInfo(rsrc, refs);
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ public class ListDashboards implements RestReadView<ProjectResource> {
|
|||||||
}
|
}
|
||||||
return all;
|
return all;
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(project, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -217,7 +217,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
|||||||
try {
|
try {
|
||||||
return repoManager.openRepository(project);
|
return repoManager.openRepository(project);
|
||||||
} catch (RepositoryNotFoundException noGitRepository) {
|
} catch (RepositoryNotFoundException noGitRepository) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException(project.get(), noGitRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -178,7 +178,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
|||||||
uiActions,
|
uiActions,
|
||||||
views);
|
views);
|
||||||
} catch (RepositoryNotFoundException notFound) {
|
} catch (RepositoryNotFoundException notFound) {
|
||||||
throw new ResourceNotFoundException(projectName.get());
|
throw new ResourceNotFoundException(projectName.get(), notFound);
|
||||||
} catch (ConfigInvalidException err) {
|
} catch (ConfigInvalidException err) {
|
||||||
throw new ResourceConflictException("Cannot read project " + projectName, err);
|
throw new ResourceConflictException("Cannot read project " + projectName, err);
|
||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
|
@@ -92,7 +92,7 @@ public class PutDescription implements RestModifyView<ProjectResource, Descripti
|
|||||||
? Response.none()
|
? Response.none()
|
||||||
: Response.ok(project.getDescription());
|
: Response.ok(project.getDescription());
|
||||||
} catch (RepositoryNotFoundException notFound) {
|
} catch (RepositoryNotFoundException notFound) {
|
||||||
throw new ResourceNotFoundException(resource.getName());
|
throw new ResourceNotFoundException(resource.getName(), notFound);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
String.format("invalid project.config: %s", e.getMessage()));
|
String.format("invalid project.config: %s", e.getMessage()));
|
||||||
|
@@ -135,7 +135,7 @@ public class SetAccess implements RestModifyView<ProjectResource, ProjectAccessI
|
|||||||
} catch (InvalidNameException e) {
|
} catch (InvalidNameException e) {
|
||||||
throw new BadRequestException(e.toString());
|
throw new BadRequestException(e.toString());
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(rsrc.getName());
|
throw new ResourceConflictException(rsrc.getName(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAccess.apply(rsrc.getNameKey());
|
return getAccess.apply(rsrc.getNameKey());
|
||||||
|
@@ -89,7 +89,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, SetDashbo
|
|||||||
new ProjectResource(rsrc.getProjectState(), rsrc.getUser()),
|
new ProjectResource(rsrc.getProjectState(), rsrc.getUser()),
|
||||||
IdString.fromUrl(input.id));
|
IdString.fromUrl(input.id));
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
throw new BadRequestException("dashboard " + input.id + " not found");
|
throw new BadRequestException("dashboard " + input.id + " not found", e);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(e.getMessage());
|
throw new ResourceConflictException(e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, SetDashbo
|
|||||||
}
|
}
|
||||||
return Response.none();
|
return Response.none();
|
||||||
} catch (RepositoryNotFoundException notFound) {
|
} catch (RepositoryNotFoundException notFound) {
|
||||||
throw new ResourceNotFoundException(rsrc.getProjectState().getProject().getName());
|
throw new ResourceNotFoundException(rsrc.getProjectState().getProject().getName(), notFound);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
String.format("invalid project.config: %s", e.getMessage()));
|
String.format("invalid project.config: %s", e.getMessage()));
|
||||||
|
@@ -111,7 +111,7 @@ public class SetHead implements RestModifyView<ProjectResource, HeadInput> {
|
|||||||
}
|
}
|
||||||
return ref;
|
return ref;
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw new ResourceNotFoundException(rsrc.getName());
|
throw new ResourceNotFoundException(rsrc.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -120,7 +120,7 @@ public class SetParent
|
|||||||
requireNonNull(parent);
|
requireNonNull(parent);
|
||||||
return parent.get();
|
return parent.get();
|
||||||
} catch (RepositoryNotFoundException notFound) {
|
} catch (RepositoryNotFoundException notFound) {
|
||||||
throw new ResourceNotFoundException(rsrc.getName());
|
throw new ResourceNotFoundException(rsrc.getName(), notFound);
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
String.format("invalid project.config: %s", e.getMessage()));
|
String.format("invalid project.config: %s", e.getMessage()));
|
||||||
|
@@ -58,7 +58,8 @@ public final class StoredValues {
|
|||||||
try {
|
try {
|
||||||
return cd.change();
|
return cd.change();
|
||||||
} catch (StorageException e) {
|
} 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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ public final class StoredValues {
|
|||||||
try {
|
try {
|
||||||
patchList = plCache.get(plKey, project);
|
patchList = plCache.get(plKey, project);
|
||||||
} catch (PatchListNotAvailableException e) {
|
} catch (PatchListNotAvailableException e) {
|
||||||
throw new SystemException("Cannot create " + plKey);
|
throw new SystemException(String.format("Cannot create %s: %s", plKey, e.getMessage()));
|
||||||
}
|
}
|
||||||
return patchList;
|
return patchList;
|
||||||
}
|
}
|
||||||
|
@@ -104,7 +104,7 @@ public class NoteDbSchemaUpdater {
|
|||||||
try {
|
try {
|
||||||
schemaCreator.ensureCreated();
|
schemaCreator.ensureCreated();
|
||||||
} catch (IOException | ConfigInvalidException e) {
|
} 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) {
|
} catch (MergeConflictException mce) {
|
||||||
// Unlike in Cherry-pick case, this should never happen.
|
// Unlike in Cherry-pick case, this should never happen.
|
||||||
toMerge.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
|
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) {
|
} catch (MergeIdenticalTreeException mie) {
|
||||||
// this should not happen
|
// this should not happen
|
||||||
toMerge.setStatusCode(SKIPPED_IDENTICAL_TREE);
|
toMerge.setStatusCode(SKIPPED_IDENTICAL_TREE);
|
||||||
|
@@ -549,7 +549,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
|
|||||||
return args.submoduleOp.composeGitlinksCommit(args.destBranch, commit);
|
return args.submoduleOp.composeGitlinksCommit(args.destBranch, commit);
|
||||||
} catch (SubmoduleException | IOException e) {
|
} catch (SubmoduleException | IOException e) {
|
||||||
throw new IntegrationException(
|
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 {
|
try {
|
||||||
port = Integer.parseInt(portStr);
|
port = Integer.parseInt(portStr);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("invalid port: " + desc);
|
throw new IllegalArgumentException("invalid port: " + desc, e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
port = defaultPort;
|
port = defaultPort;
|
||||||
|
@@ -385,6 +385,10 @@ public abstract class BaseCommand implements Command {
|
|||||||
return new UnloggedFailure(1, "fatal: " + msg);
|
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) {
|
protected UnloggedFailure die(Throwable why) {
|
||||||
return new UnloggedFailure(1, "fatal: " + why.getMessage(), why);
|
return new UnloggedFailure(1, "fatal: " + why.getMessage(), why);
|
||||||
}
|
}
|
||||||
|
@@ -111,7 +111,7 @@ public class ChangeArgumentParser {
|
|||||||
try {
|
try {
|
||||||
changeResource = changesCollection.parse(cId);
|
changeResource = changesCollection.parse(cId);
|
||||||
} catch (RestApiException e) {
|
} catch (RestApiException e) {
|
||||||
throw new UnloggedFailure(1, "\"" + id + "\" no such change");
|
throw new UnloggedFailure(1, "\"" + id + "\" no such change", e);
|
||||||
}
|
}
|
||||||
changes.put(cId, changeResource);
|
changes.put(cId, changeResource);
|
||||||
}
|
}
|
||||||
|
@@ -34,11 +34,10 @@ public class SshKeyCreatorImpl implements SshKeyCreator {
|
|||||||
SshUtil.parse(key);
|
SshUtil.parse(key);
|
||||||
return key;
|
return key;
|
||||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||||
throw new InvalidSshKeyException();
|
throw new InvalidSshKeyException(e);
|
||||||
|
|
||||||
} catch (NoSuchProviderException e) {
|
} catch (NoSuchProviderException e) {
|
||||||
logger.atSevere().withCause(e).log("Cannot parse SSH key");
|
logger.atSevere().withCause(e).log("Cannot parse SSH key");
|
||||||
throw new InvalidSshKeyException();
|
throw new InvalidSshKeyException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -126,9 +126,9 @@ public final class SuExec extends BaseCommand {
|
|||||||
try {
|
try {
|
||||||
permissionBackend.user(caller).check(GlobalPermission.RUN_AS);
|
permissionBackend.user(caller).check(GlobalPermission.RUN_AS);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw die("suexec not permitted");
|
throw die("suexec not permitted", e);
|
||||||
} catch (PermissionBackendException 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);
|
throw new Failure(1, "fatal: Error reading refs: '" + projectName, e);
|
||||||
}
|
}
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
throw die("'" + projectName + "': not a git archive");
|
throw die("'" + projectName + "': not a git archive", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw die("Error opening: '" + projectName);
|
throw die("Error opening: '" + projectName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -99,7 +99,7 @@ public class PatchSetParser {
|
|||||||
try {
|
try {
|
||||||
patchSetId = PatchSet.Id.parse(token);
|
patchSetId = PatchSet.Id.parse(token);
|
||||||
} catch (IllegalArgumentException e) {
|
} 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.getParentKey());
|
ChangeNotes notes = getNotes(projectState, patchSetId.getParentKey());
|
||||||
PatchSet patchSet = psUtil.get(notes, patchSetId);
|
PatchSet patchSet = psUtil.get(notes, patchSetId);
|
||||||
@@ -130,7 +130,7 @@ public class PatchSetParser {
|
|||||||
ChangeNotes notes = changeFinder.findOne(changeId);
|
ChangeNotes notes = changeFinder.findOne(changeId);
|
||||||
return notesFactory.create(notes.getProjectName(), changeId);
|
return notesFactory.create(notes.getProjectName(), changeId);
|
||||||
} catch (NoSuchChangeException e) {
|
} 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) {
|
public static UnloggedFailure error(String msg) {
|
||||||
return new UnloggedFailure(1, 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 {
|
try {
|
||||||
data = Files.newInputStream(new File(source).toPath());
|
data = Files.newInputStream(new File(source).toPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw die("cannot read " + source);
|
throw die("cannot read " + source, e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
data = new URL(source).openStream();
|
data = new URL(source).openStream();
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw die("invalid url " + source);
|
throw die("invalid url " + source, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw die("cannot read " + source);
|
throw die("cannot read " + source, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
loader.installPluginFromStream(name, data);
|
loader.installPluginFromStream(name, data);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw die("cannot install plugin");
|
throw die("cannot install plugin", e);
|
||||||
} catch (PluginInstallException e) {
|
} catch (PluginInstallException e) {
|
||||||
e.printStackTrace(stderr);
|
e.printStackTrace(stderr);
|
||||||
String msg = String.format("Plugin failed to install. Cause: %s", e.getMessage());
|
String msg = String.format("Plugin failed to install. Cause: %s", e.getMessage());
|
||||||
|
@@ -83,7 +83,7 @@ final class Receive extends AbstractGitCommand {
|
|||||||
.project(project.getNameKey())
|
.project(project.getNameKey())
|
||||||
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
.check(ProjectPermission.RUN_RECEIVE_PACK);
|
||||||
} catch (AuthException e) {
|
} 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) {
|
} catch (PermissionBackendException e) {
|
||||||
throw new Failure(1, "fatal: unable to check permissions " + e);
|
throw new Failure(1, "fatal: unable to check permissions " + e);
|
||||||
}
|
}
|
||||||
|
@@ -326,7 +326,7 @@ public class ReviewCommand extends SshCommand {
|
|||||||
try {
|
try {
|
||||||
allProjectsState = projectCache.checkedGet(allProjects);
|
allProjectsState = projectCache.checkedGet(allProjects);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw die("missing " + allProjects.get());
|
throw die("missing " + allProjects.get(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LabelType type : allProjectsState.getLabelTypes().getLabelTypes()) {
|
for (LabelType type : allProjectsState.getLabelTypes().getLabelTypes()) {
|
||||||
|
@@ -55,9 +55,9 @@ final class Upload extends AbstractGitCommand {
|
|||||||
|
|
||||||
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
|
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
throw new Failure(1, "fatal: upload-pack not permitted on this server");
|
throw new Failure(1, "fatal: upload-pack not permitted on this server", e);
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
throw new Failure(1, "fatal: unable to check permissions " + e);
|
throw new Failure(1, "fatal: unable to check permissions ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final UploadPack up = new UploadPack(repo);
|
final UploadPack up = new UploadPack(repo);
|
||||||
|
@@ -100,7 +100,7 @@ public class StandardKeyEncoder extends Encoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ArrayIndexOutOfBoundsException err) {
|
} catch (ArrayIndexOutOfBoundsException err) {
|
||||||
throw new IllegalArgumentException("Bad encoding: " + e);
|
throw new IllegalArgumentException("Bad encoding" + e, err);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new String(b, 0, bPtr, "UTF-8");
|
return new String(b, 0, bPtr, "UTF-8");
|
||||||
|
@@ -83,6 +83,7 @@ java_package_configuration(
|
|||||||
"-Xep:TypeParameterUnusedInFormals:WARN",
|
"-Xep:TypeParameterUnusedInFormals:WARN",
|
||||||
"-Xep:URLEqualsHashCode:WARN",
|
"-Xep:URLEqualsHashCode:WARN",
|
||||||
"-Xep:UnsynchronizedOverridesSynchronized:WARN",
|
"-Xep:UnsynchronizedOverridesSynchronized:WARN",
|
||||||
|
"-Xep:UnusedException:ERROR",
|
||||||
"-Xep:WaitNotInLoop:WARN",
|
"-Xep:WaitNotInLoop:WARN",
|
||||||
],
|
],
|
||||||
packages = ["error_prone_packages"],
|
packages = ["error_prone_packages"],
|
||||||
|
Reference in New Issue
Block a user