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:
		| @@ -232,7 +232,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); | ||||||
|       } |       } | ||||||
| @@ -307,7 +307,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); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -220,8 +220,11 @@ public abstract class StandaloneSiteTest { | |||||||
|     try { |     try { | ||||||
|       status = p.waitFor(); |       status = p.waitFor(); | ||||||
|     } catch (InterruptedException e) { |     } catch (InterruptedException e) { | ||||||
|       throw new InterruptedIOException( |       InterruptedIOException iioe = | ||||||
|  |           new InterruptedIOException( | ||||||
|               "interrupted waiting for: " + Joiner.on(' ').join(pb.command())); |               "interrupted waiting for: " + Joiner.on(' ').join(pb.command())); | ||||||
|  |       iioe.initCause(e); | ||||||
|  |       throw iioe; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String result = new String(out, UTF_8); |     String result = new String(out, UTF_8); | ||||||
|   | |||||||
| @@ -97,7 +97,7 @@ public class KeyUtil { | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } 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"); | ||||||
|   | |||||||
| @@ -23,4 +23,8 @@ public class InvalidSshKeyException extends Exception { | |||||||
|   public InvalidSshKeyException() { |   public InvalidSshKeyException() { | ||||||
|     super(MESSAGE); |     super(MESSAGE); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public InvalidSshKeyException(Throwable cause) { | ||||||
|  |     super(MESSAGE, cause); | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -22,4 +22,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); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public ResourceNotFoundException caching(CacheControl c) { |   public ResourceNotFoundException caching(CacheControl c) { | ||||||
|     setCaching(c); |     setCaching(c); | ||||||
|     return this; |     return this; | ||||||
|   | |||||||
| @@ -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)); | ||||||
|   | |||||||
| @@ -1182,7 +1182,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); | ||||||
|   | |||||||
| @@ -208,7 +208,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 intTermQuery.get(p.getField().getName(), value); |     return intTermQuery.get(p.getField().getName(), value); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -332,7 +332,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()); | ||||||
|   | |||||||
| @@ -331,7 +331,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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -391,7 +391,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.entities.Account; | import com.google.gerrit.entities.Account; | ||||||
| @@ -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.entities.Account; | import com.google.gerrit.entities.Account; | ||||||
| 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; | ||||||
| @@ -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() {} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -760,6 +760,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) { | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ public class PermissionAwareReadOnlyRefDatabase extends DelegateRefDatabase { | |||||||
|     try { |     try { | ||||||
|       result = forProject.filter(refs, getDelegate(), RefFilterOptions.defaults()); |       result = forProject.filter(refs, getDelegate(), RefFilterOptions.defaults()); | ||||||
|     } catch (PermissionBackendException e) { |     } catch (PermissionBackendException e) { | ||||||
|       throw new IOException(""); |       throw new IOException("", e); | ||||||
|     } |     } | ||||||
|     return buildPrefixRefMap(prefix, result); |     return buildPrefixRefMap(prefix, result); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -166,7 +166,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"); | ||||||
|   | |||||||
| @@ -32,6 +32,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); | ||||||
|   | |||||||
| @@ -500,7 +500,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"); | ||||||
| @@ -597,7 +597,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"); | ||||||
| @@ -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 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"); | ||||||
| @@ -665,7 +665,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"); | ||||||
| @@ -704,7 +704,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); | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -192,7 +192,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"); | ||||||
| @@ -204,7 +204,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"); | ||||||
| @@ -245,7 +245,7 @@ public class MergeValidators { | |||||||
|             } |             } | ||||||
|           } |           } | ||||||
|         } catch (ConfigInvalidException | IOException e) { |         } catch (ConfigInvalidException | IOException e) { | ||||||
|           throw new MergeValidationException(INVALID_CONFIG); |           throw new MergeValidationException(INVALID_CONFIG, e); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -134,7 +134,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( | ||||||
| @@ -145,7 +145,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); | ||||||
|             } |             } | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -293,7 +293,7 @@ public abstract class ChangeEmail extends NotificationEmail { | |||||||
|       try { |       try { | ||||||
|         ps = args.patchSetUtil.get(changeData.notes(), PatchSet.id(change.getId(), patchSetId)); |         ps = args.patchSetUtil.get(changeData.notes(), 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); | ||||||
|   | |||||||
| @@ -907,7 +907,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); | ||||||
|   | |||||||
| @@ -193,7 +193,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); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) { |     if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) { | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ public class PatchScriptFactoryForAutoFix 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); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) { |     if (!projectCache.checkedGet(notes.getProjectName()).statePermitsRead()) { | ||||||
|   | |||||||
| @@ -132,9 +132,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); | ||||||
|   | |||||||
| @@ -1288,7 +1288,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData, ChangeQueryBuil | |||||||
|         throw new QueryParseException( |         throw new QueryParseException( | ||||||
|             "'" |             "'" | ||||||
|                 + value |                 + 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( |     throw new QueryParseException( | ||||||
|   | |||||||
| @@ -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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -163,7 +163,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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -100,7 +100,7 @@ public class PutAgreement implements RestModifyView<AccountResource, AgreementIn | |||||||
|     try { |     try { | ||||||
|       addMembers.addMembers(uuid, ImmutableSet.of(accountState.account().id())); |       addMembers.addMembers(uuid, ImmutableSet.of(accountState.account().id())); | ||||||
|     } 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); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -122,7 +122,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 { | ||||||
|   | |||||||
| @@ -422,7 +422,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; | ||||||
|   | |||||||
| @@ -205,7 +205,7 @@ public class CreateMergePatchSet implements RestModifyView<ChangeResource, Merge | |||||||
|     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); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -293,6 +293,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\""), | ||||||
|   | |||||||
| @@ -514,7 +514,8 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput> | |||||||
|           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); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| @@ -530,7 +531,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput> | |||||||
|       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( | ||||||
| @@ -580,7 +581,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput> | |||||||
|         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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -174,7 +174,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); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -94,7 +94,7 @@ public class PutAssignee | |||||||
|           .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 = | ||||||
|   | |||||||
| @@ -129,7 +129,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); | ||||||
|   | |||||||
| @@ -438,7 +438,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; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -88,7 +88,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); | ||||||
|   | |||||||
| @@ -138,7 +138,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 Response.ok(toAccountInfoList(newMemberIds)); |     return Response.ok(toAccountInfoList(newMemberIds)); | ||||||
|   } |   } | ||||||
| @@ -234,7 +234,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 Response.ok(result); |     return Response.ok(result); | ||||||
|   } |   } | ||||||
| @@ -153,7 +153,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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -220,7 +220,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -78,7 +78,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(); | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ public class GetOwner implements RestReadView<GroupResource> { | |||||||
|       GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID()); |       GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID()); | ||||||
|       return Response.ok(json.format(c.getGroup())); |       return Response.ok(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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -79,9 +79,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -66,7 +66,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); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -77,7 +77,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 Response.ok(json.format(owner)); |     return Response.ok(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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -87,7 +87,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()); | ||||||
| @@ -102,7 +102,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(); | ||||||
|   | |||||||
| @@ -127,7 +127,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); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
| @@ -197,7 +197,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -149,7 +149,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -165,7 +165,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. | ||||||
|   | |||||||
| @@ -82,13 +82,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -104,7 +104,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()); | ||||||
|   | |||||||
| @@ -51,7 +51,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -149,7 +149,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -165,7 +165,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); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -120,7 +120,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -219,7 +219,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -190,7 +190,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())); | ||||||
|   | |||||||
| @@ -130,7 +130,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 Response.ok(getAccess.apply(rsrc.getNameKey())); |     return Response.ok(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())); | ||||||
|   | |||||||
| @@ -114,7 +114,7 @@ public class SetHead implements RestModifyView<ProjectResource, HeadInput> { | |||||||
|       } |       } | ||||||
|       return Response.ok(ref); |       return Response.ok(ref); | ||||||
|     } catch (RepositoryNotFoundException e) { |     } catch (RepositoryNotFoundException e) { | ||||||
|       throw new ResourceNotFoundException(rsrc.getName()); |       throw new ResourceNotFoundException(rsrc.getName(), e); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -121,7 +121,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())); | ||||||
|   | |||||||
| @@ -57,7 +57,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())); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -101,7 +102,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); | ||||||
|   | |||||||
| @@ -550,7 +550,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; | ||||||
|   | |||||||
| @@ -387,6 +387,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); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -127,9 +127,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.changeId()); |       ChangeNotes notes = getNotes(projectState, patchSetId.changeId()); | ||||||
|       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()); | ||||||
|   | |||||||
| @@ -78,7 +78,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); | ||||||
|     } |     } | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse