Use try/multi-catch

Change-Id: Icf5042cccb0662d6bd53302800e03211af94c16d
This commit is contained in:
Urs Wolfer
2015-06-24 20:06:25 +02:00
committed by David Pursehouse
parent 8702786e5a
commit 64cfaf242d
39 changed files with 51 additions and 174 deletions

View File

@@ -110,9 +110,7 @@ public class GerritServer {
public void run() { public void run() {
try { try {
serverStarted.await(); serverStarted.await();
} catch (InterruptedException e) { } catch (InterruptedException | BrokenBarrierException e) {
throw new RuntimeException(e);
} catch (BrokenBarrierException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@@ -98,10 +98,7 @@ public class PrivateInternals_DynamicTypes {
handles.add(item.set(b.getKey(), b.getProvider(), pluginName)); handles.add(item.set(b.getKey(), b.getProvider(), pluginName));
} }
} }
} catch (RuntimeException e) { } catch (RuntimeException | Error e) {
remove(handles);
throw e;
} catch (Error e) {
remove(handles); remove(handles);
throw e; throw e;
} }
@@ -130,10 +127,7 @@ public class PrivateInternals_DynamicTypes {
} }
} }
} }
} catch (RuntimeException e) { } catch (RuntimeException | Error e) {
remove(handles);
throw e;
} catch (Error e) {
remove(handles); remove(handles);
throw e; throw e;
} }
@@ -164,10 +158,7 @@ public class PrivateInternals_DynamicTypes {
} }
} }
} }
} catch (RuntimeException e) { } catch (RuntimeException | Error e) {
remove(handles);
throw e;
} catch (Error e) {
remove(handles); remove(handles);
throw e; throw e;
} }

View File

@@ -238,11 +238,7 @@ public class CatServlet extends HttpServlet {
return; return;
} }
} }
} catch (IOException e) { } catch (IOException | RuntimeException e) {
getServletContext().log("Cannot read repository", e);
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
} catch (RuntimeException e) {
getServletContext().log("Cannot read repository", e); getServletContext().log("Cannot read repository", e);
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return; return;

View File

@@ -66,13 +66,8 @@ public abstract class Handler<T> implements Callable<T> {
if (r != null) { if (r != null) {
callback.onSuccess(r); callback.onSuccess(r);
} }
} catch (NoSuchProjectException e) { } catch (NoSuchProjectException | NoSuchChangeException
callback.onFailure(new NoSuchEntityException()); | NoSuchRefException e) {
} catch (NoSuchRefException e) {
callback.onFailure(new NoSuchEntityException());
} catch (NoSuchChangeException e) {
callback.onFailure(new NoSuchEntityException()); callback.onFailure(new NoSuchEntityException());
} catch (OrmException e) { } catch (OrmException e) {

View File

@@ -234,11 +234,8 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
} else { } else {
throw new EmailTokenVerifier.InvalidTokenException(); throw new EmailTokenVerifier.InvalidTokenException();
} }
} catch (EmailTokenVerifier.InvalidTokenException e) { } catch (EmailTokenVerifier.InvalidTokenException | OrmException
callback.onFailure(e); | AccountException e) {
} catch (AccountException e) {
callback.onFailure(e);
} catch (OrmException e) {
callback.onFailure(e); callback.onFailure(e);
} }
} }

View File

@@ -146,9 +146,7 @@ public abstract class ProjectAccessHandler<T> extends Handler<T> {
"You are not allowed to change the parent project since you are " "You are not allowed to change the parent project since you are "
+ "not an administrator. You may save the modifications for review " + "not an administrator. You may save the modifications for review "
+ "so that an administrator can approve them.", e); + "so that an administrator can approve them.", e);
} catch (ResourceConflictException e) { } catch (ResourceConflictException | UnprocessableEntityException e) {
throw new UpdateParentFailedException(e.getMessage(), e);
} catch (UnprocessableEntityException e) {
throw new UpdateParentFailedException(e.getMessage(), e); throw new UpdateParentFailedException(e.getMessage(), e);
} }
config.getProject().setParentName(parentProjectName); config.getProject().setParentName(parentProjectName);

View File

@@ -115,9 +115,7 @@ class LuceneVersionManager implements LifecycleListener {
FileBasedConfig cfg; FileBasedConfig cfg;
try { try {
cfg = loadGerritIndexConfig(sitePaths); cfg = loadGerritIndexConfig(sitePaths);
} catch (ConfigInvalidException e) { } catch (ConfigInvalidException | IOException e) {
throw fail(e);
} catch (IOException e) {
throw fail(e); throw fail(e);
} }

View File

@@ -145,9 +145,7 @@ public class AuthSMTPClient extends SMTPClient {
Mac mac = Mac.getInstance(macName); Mac mac = Mac.getInstance(macName);
mac.init(new SecretKeySpec(smtpPass.getBytes(UTF_8), macName)); mac.init(new SecretKeySpec(smtpPass.getBytes(UTF_8), macName));
sec = toHex(mac.doFinal(nonce)); sec = toHex(mac.doFinal(nonce));
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | InvalidKeyException e) {
throw new IOException("Cannot use CRAM-" + alg, e);
} catch (InvalidKeyException e) {
throw new IOException("Cannot use CRAM-" + alg, e); throw new IOException("Cannot use CRAM-" + alg, e);
} }

View File

@@ -80,9 +80,7 @@ public class JythonShell {
try { try {
shell = console.newInstance(); shell = console.newInstance();
log.info("Jython shell instance created."); log.info("Jython shell instance created.");
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException e) {
throw noInterpreter(e);
} catch (IllegalAccessException e) {
throw noInterpreter(e); throw noInterpreter(e);
} }
injectedVariables = new ArrayList<>(); injectedVariables = new ArrayList<>();
@@ -96,13 +94,8 @@ public class JythonShell {
Method m; Method m;
m = klazz.getMethod(name, sig); m = klazz.getMethod(name, sig);
return m.invoke(instance, args); return m.invoke(instance, args);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | IllegalAccessException
throw cannotStart(e); | IllegalArgumentException | SecurityException e) {
} catch (SecurityException e) {
throw cannotStart(e);
} catch (IllegalArgumentException e) {
throw cannotStart(e);
} catch (IllegalAccessException e) {
throw cannotStart(e); throw cannotStart(e);
} }
} }

View File

@@ -125,12 +125,7 @@ public class BaseInit extends SiteProgram {
run.upgradeSchema(); run.upgradeSchema();
init.initializer.postRun(createSysInjector(init)); init.initializer.postRun(createSysInjector(init));
} catch (Exception failure) { } catch (Exception | Error failure) {
if (init.flags.deleteOnFailure) {
recursiveDelete(getSitePath());
}
throw failure;
} catch (Error failure) {
if (init.flags.deleteOnFailure) { if (init.flags.deleteOnFailure) {
recursiveDelete(getSitePath()); recursiveDelete(getSitePath());
} }

View File

@@ -53,9 +53,7 @@ class Libraries {
final Config cfg = new Config(); final Config cfg = new Config();
try { try {
cfg.fromText(read(RESOURCE_FILE)); cfg.fromText(read(RESOURCE_FILE));
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
throw new RuntimeException(e.getMessage(), e);
} catch (ConfigInvalidException e) {
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} }

View File

@@ -45,15 +45,9 @@ public abstract class ConsoleUI {
protected static <T extends Enum<?>> T[] all(final T value) { protected static <T extends Enum<?>> T[] all(final T value) {
try { try {
return (T[]) value.getClass().getMethod("values").invoke(null); return (T[]) value.getClass().getMethod("values").invoke(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | NoSuchMethodException
throw new IllegalArgumentException("Cannot obtain enumeration values", e); | InvocationTargetException | IllegalAccessException
} catch (SecurityException e) { | SecurityException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e); throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} }
} }

View File

@@ -228,9 +228,7 @@ public class LdapGroupBackend implements GroupBackend {
log.warn("Cannot close LDAP query handle", e); log.warn("Cannot close LDAP query handle", e);
} }
} }
} catch (NamingException e) { } catch (NamingException | LoginException e) {
log.warn("Cannot query LDAP for groups matching requested name", e);
} catch (LoginException e) {
log.warn("Cannot query LDAP for groups matching requested name", e); log.warn("Cannot query LDAP for groups matching requested name", e);
} }
return out; return out;

View File

@@ -31,15 +31,9 @@ public class ConfigUtil {
private static <T> T[] allValuesOf(final T defaultValue) { private static <T> T[] allValuesOf(final T defaultValue) {
try { try {
return (T[]) defaultValue.getClass().getMethod("values").invoke(null); return (T[]) defaultValue.getClass().getMethod("values").invoke(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | NoSuchMethodException
throw new IllegalArgumentException("Cannot obtain enumeration values", e); | InvocationTargetException | IllegalAccessException
} catch (SecurityException e) { | SecurityException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Cannot obtain enumeration values", e); throw new IllegalArgumentException("Cannot obtain enumeration values", e);
} }
} }

View File

@@ -55,9 +55,7 @@ class GerritServerConfigProvider implements Provider<Config> {
try { try {
cfg.load(); cfg.load();
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
throw new ProvisionException(e.getMessage(), e);
} catch (ConfigInvalidException e) {
throw new ProvisionException(e.getMessage(), e); throw new ProvisionException(e.getMessage(), e);
} }

View File

@@ -264,9 +264,7 @@ public class PluginConfigFactory implements ReloadPluginListener {
try { try {
cfg.load(); cfg.load();
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
log.warn("Failed to load " + pluginConfigFile.toAbsolutePath(), e);
} catch (ConfigInvalidException e) {
log.warn("Failed to load " + pluginConfigFile.toAbsolutePath(), e); log.warn("Failed to load " + pluginConfigFile.toAbsolutePath(), e);
} }

View File

@@ -94,9 +94,7 @@ public class QueryDocumentationExecutor {
out.add(result); out.add(result);
} }
return out; return out;
} catch (IOException e) { } catch (IOException | ParseException e) {
throw new DocQueryException(e);
} catch (ParseException e) {
throw new DocQueryException(e); throw new DocQueryException(e);
} }
} }

View File

@@ -355,8 +355,6 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
f.write(Constants.encode(d)); f.write(Constants.encode(d));
f.commit(); f.commit();
} }
} catch (RepositoryNotFoundException e) {
log.error("Cannot update description for " + name, e);
} catch (IOException e) { } catch (IOException e) {
log.error("Cannot update description for " + name, e); log.error("Cannot update description for " + name, e);
} }

View File

@@ -831,9 +831,7 @@ public class MergeOp {
message(c, "Unspecified merge failure: " + s.name())); message(c, "Unspecified merge failure: " + s.name()));
break; break;
} }
} catch (OrmException err) { } catch (OrmException | IOException err) {
logWarn("Error updating change status for " + c.getId(), err);
} catch (IOException err) {
logWarn("Error updating change status for " + c.getId(), err); logWarn("Error updating change status for " + c.getId(), err);
} }
} }

View File

@@ -736,12 +736,7 @@ public class ReceiveCommits {
if (replace.insertPatchSet().checkedGet() != null) { if (replace.insertPatchSet().checkedGet() != null) {
replace.inputCommand.setResult(OK); replace.inputCommand.setResult(OK);
} }
} catch (IOException err) { } catch (IOException | InsertException err) {
reject(replace.inputCommand, "internal server error");
log.error(String.format(
"Cannot add patch set to %d of %s",
e.getKey().get(), project.getName()), err);
} catch (InsertException err) {
reject(replace.inputCommand, "internal server error"); reject(replace.inputCommand, "internal server error");
log.error(String.format( log.error(String.format(
"Cannot add patch set to %d of %s", "Cannot add patch set to %d of %s",
@@ -2593,9 +2588,7 @@ public class ReceiveCommits {
currentUser.getAccount()).update(); currentUser.getAccount()).update();
} catch (InsertException e) { } catch (InsertException e) {
log.error("Can't insert patchset", e); log.error("Can't insert patchset", e);
} catch (IOException e) { } catch (IOException | OrmException e) {
log.error("Can't scan for changes to close", e);
} catch (OrmException e) {
log.error("Can't scan for changes to close", e); log.error("Can't scan for changes to close", e);
} catch (SubmoduleException e) { } catch (SubmoduleException e) {
log.error("Can't complete git links check", e); log.error("Can't complete git links check", e);

View File

@@ -92,9 +92,7 @@ public class RenameGroupOp extends DefaultQueueOp {
} }
} catch (RepositoryNotFoundException noProject) { } catch (RepositoryNotFoundException noProject) {
continue; continue;
} catch (ConfigInvalidException err) { } catch (ConfigInvalidException | IOException err) {
log.error("Cannot rename group " + oldName + " in " + projectName, err);
} catch (IOException err) {
log.error("Cannot rename group " + oldName + " in " + projectName, err); log.error("Cannot rename group " + oldName + " in " + projectName, err);
} }
} }

View File

@@ -159,8 +159,8 @@ public class GroupsCollection implements
try { try {
AccountGroup.Id legacyId = AccountGroup.Id.parse(id); AccountGroup.Id legacyId = AccountGroup.Id.parse(id);
return groupControlFactory.controlFor(legacyId).getGroup(); return groupControlFactory.controlFor(legacyId).getGroup();
} catch (IllegalArgumentException invalidId) { } catch (IllegalArgumentException | NoSuchGroupException e) {
} catch (NoSuchGroupException e) { // Ignored
} }
} }

View File

@@ -308,9 +308,7 @@ public class ChangeSchemas {
checkArgument(f.getName().startsWith("V")); checkArgument(f.getName().startsWith("V"));
schema.setVersion(Integer.parseInt(f.getName().substring(1))); schema.setVersion(Integer.parseInt(f.getName().substring(1)));
all.put(schema.getVersion(), schema); all.put(schema.getVersion(), schema);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
throw new ExceptionInInitializerError(e);
} catch (IllegalAccessException e) {
throw new ExceptionInInitializerError(e); throw new ExceptionInInitializerError(e);
} }
} else { } else {

View File

@@ -53,9 +53,7 @@ public class SignedTokenEmailTokenVerifier implements EmailTokenVerifier {
byte[] utf8 = payload.getBytes("UTF-8"); byte[] utf8 = payload.getBytes("UTF-8");
String base64 = Base64.encodeBytes(utf8); String base64 = Base64.encodeBytes(utf8);
return emailRegistrationToken.newToken(base64); return emailRegistrationToken.newToken(base64);
} catch (XsrfException e) { } catch (XsrfException | UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }
} }

View File

@@ -31,7 +31,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.zip.ZipException; import java.util.zip.ZipException;
@@ -66,8 +65,6 @@ class InstallPlugin implements RestModifyView<TopLevelResource, Input> {
} else { } else {
try { try {
in = new URL(input.url).openStream(); in = new URL(input.url).openStream();
} catch (MalformedURLException e) {
throw new BadRequestException(e.getMessage());
} catch (IOException e) { } catch (IOException e) {
throw new BadRequestException(e.getMessage()); throw new BadRequestException(e.getMessage());
} }

View File

@@ -239,9 +239,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
} }
rw.checkConnectivity(); rw.checkConnectivity();
return rw; return rw;
} catch (IncorrectObjectTypeException err) { } catch (IncorrectObjectTypeException | MissingObjectException err) {
throw new InvalidRevisionException();
} catch (MissingObjectException err) {
throw new InvalidRevisionException(); throw new InvalidRevisionException();
} catch (IOException err) { } catch (IOException err) {
log.error("Repository \"" + repo.getDirectory() log.error("Repository \"" + repo.getDirectory()

View File

@@ -106,11 +106,8 @@ class DashboardsCollection implements
for (ProjectState ps : myCtl.getProjectState().tree()) { for (ProjectState ps : myCtl.getProjectState().tree()) {
try { try {
return parse(ps.controlFor(user), ref, path, myCtl); return parse(ps.controlFor(user), ref, path, myCtl);
} catch (AmbiguousObjectException e) { } catch (AmbiguousObjectException | ConfigInvalidException
throw new ResourceNotFoundException(id); | IncorrectObjectTypeException e) {
} catch (IncorrectObjectTypeException e) {
throw new ResourceNotFoundException(id);
} catch (ConfigInvalidException e) {
throw new ResourceNotFoundException(id); throw new ResourceNotFoundException(id);
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
continue; continue;

View File

@@ -48,9 +48,7 @@ public class GetStatistics implements RestReadView<ProjectResource> {
try (Repository repo = repoManager.openRepository(rsrc.getNameKey())) { try (Repository repo = repoManager.openRepository(rsrc.getNameKey())) {
GarbageCollectCommand gc = Git.wrap(repo).gc(); GarbageCollectCommand gc = Git.wrap(repo).gc();
return new RepositoryStatistics(gc.getStatistics()); return new RepositoryStatistics(gc.getStatistics());
} catch (GitAPIException e) { } catch (GitAPIException | JGitInternalException e) {
throw new ResourceConflictException(e.getMessage());
} catch (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());

View File

@@ -225,9 +225,7 @@ public class ProjectState {
ProjectLevelConfig cfg = new ProjectLevelConfig(fileName, this); ProjectLevelConfig cfg = new ProjectLevelConfig(fileName, this);
try (Repository git = gitMgr.openRepository(getProject().getNameKey())) { try (Repository git = gitMgr.openRepository(getProject().getNameKey())) {
cfg.load(git); cfg.load(git);
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
log.warn("Failed to load " + fileName + " for " + getProject().getName(), e);
} catch (ConfigInvalidException e) {
log.warn("Failed to load " + fileName + " for " + getProject().getName(), e); log.warn("Failed to load " + fileName + " for " + getProject().getName(), e);
} }

View File

@@ -350,9 +350,7 @@ public abstract class QueryBuilder<T> {
throws QueryParseException { throws QueryParseException {
try { try {
return (Predicate<T>) method.invoke(builder, value); return (Predicate<T>) method.invoke(builder, value);
} catch (RuntimeException e) { } catch (RuntimeException | IllegalAccessException e) {
throw error("Error in operator " + name + ":" + value, e);
} catch (IllegalAccessException e) {
throw error("Error in operator " + name + ":" + value, e); throw error("Error in operator " + name + ":" + value, e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
throw error("Error in operator " + name + ":" + value, e.getCause()); throw error("Error in operator " + name + ":" + value, e.getCause());

View File

@@ -96,9 +96,7 @@ public class SchemaUpdater {
if (version == null) { if (version == null) {
try { try {
creator.create(db); creator.create(db);
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
throw new OrmException("Cannot initialize schema", e);
} catch (ConfigInvalidException e) {
throw new OrmException("Cannot initialize schema", e); throw new OrmException("Cannot initialize schema", e);
} }

View File

@@ -203,11 +203,7 @@ public abstract class BaseCommand implements Command {
final CmdLineParser clp = newCmdLineParser(options); final CmdLineParser clp = newCmdLineParser(options);
try { try {
clp.parseArgument(argv); clp.parseArgument(argv);
} catch (IllegalArgumentException err) { } catch (IllegalArgumentException | CmdLineException err) {
if (!clp.wasHelpRequestedByOption()) {
throw new UnloggedFailure(1, "fatal: " + err.getMessage());
}
} catch (CmdLineException err) {
if (!clp.wasHelpRequestedByOption()) { if (!clp.wasHelpRequestedByOption()) {
throw new UnloggedFailure(1, "fatal: " + err.getMessage()); throw new UnloggedFailure(1, "fatal: " + err.getMessage());
} }

View File

@@ -195,9 +195,7 @@ class DatabasePubKeyAuth implements PublickeyAuthenticator {
try { try {
byte[] bin = Base64.decodeBase64(line.getBytes("ISO-8859-1")); byte[] bin = Base64.decodeBase64(line.getBytes("ISO-8859-1"));
keys.add(new Buffer(bin).getRawPublicKey()); keys.add(new Buffer(bin).getRawPublicKey());
} catch (RuntimeException e) { } catch (RuntimeException | SshException e) {
logBadKey(path, line, e);
} catch (SshException e) {
logBadKey(path, line, e); logBadKey(path, line, e);
} }
} }

View File

@@ -105,10 +105,7 @@ public class SshKeyCacheImpl implements SshKeyCache {
new AccountSshKey(id, SshUtil.toOpenSshPublicKey(encoded)); new AccountSshKey(id, SshUtil.toOpenSshPublicKey(encoded));
SshUtil.parse(key); SshUtil.parse(key);
return key; return key;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new InvalidSshKeyException();
} catch (InvalidKeySpecException e) {
throw new InvalidSshKeyException(); throw new InvalidSshKeyException();
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {

View File

@@ -60,9 +60,7 @@ public class SshUtil {
} }
final byte[] bin = Base64.decodeBase64(Constants.encodeASCII(s)); final byte[] bin = Base64.decodeBase64(Constants.encodeASCII(s));
return new Buffer(bin).getRawPublicKey(); return new Buffer(bin).getRawPublicKey();
} catch (RuntimeException re) { } catch (RuntimeException | SshException e) {
throw new InvalidKeySpecException("Cannot parse key", re);
} catch (SshException e) {
throw new InvalidKeySpecException("Cannot parse key", e); throw new InvalidKeySpecException("Cannot parse key", e);
} }
} }

View File

@@ -158,11 +158,7 @@ final class AdminSetParent extends SshCommand {
} }
} catch (RepositoryNotFoundException notFound) { } catch (RepositoryNotFoundException notFound) {
err.append("error: Project ").append(name).append(" not found\n"); err.append("error: Project ").append(name).append(" not found\n");
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: ").append(msg).append("\n");
} catch (ConfigInvalidException e) {
final String msg = "Cannot update project " + name; final String msg = "Cannot update project " + name;
log.error(msg, e); log.error(msg, e);
err.append("error: ").append(msg).append("\n"); err.append("error: ").append(msg).append("\n");

View File

@@ -49,9 +49,7 @@ final class PluginReloadCommand extends SshCommand {
} else { } else {
try { try {
loader.reload(names); loader.reload(names);
} catch (InvalidPluginException e) { } catch (InvalidPluginException | PluginInstallException e) {
throw die(e.getMessage());
} catch (PluginInstallException e) {
throw die(e.getMessage()); throw die(e.getMessage());
} }
} }

View File

@@ -95,10 +95,7 @@ public class QueryShell {
db.close(); db.close();
db = null; db = null;
} }
} catch (OrmException err) { } catch (OrmException | SQLException err) {
out.println("fatal: Cannot open connection: " + err.getMessage());
} catch (SQLException err) {
out.println("fatal: Cannot open connection: " + err.getMessage()); out.println("fatal: Cannot open connection: " + err.getMessage());
} finally { } finally {
out.flush(); out.flush();
@@ -123,10 +120,7 @@ public class QueryShell {
db.close(); db.close();
db = null; db = null;
} }
} catch (OrmException err) { } catch (OrmException | SQLException err) {
out.println("fatal: Cannot open connection: " + err.getMessage());
} catch (SQLException err) {
out.println("fatal: Cannot open connection: " + err.getMessage()); out.println("fatal: Cannot open connection: " + err.getMessage());
} finally { } finally {
out.flush(); out.flush();

View File

@@ -161,11 +161,7 @@ final class SetProjectCommand extends SshCommand {
} }
} catch (RepositoryNotFoundException notFound) { } catch (RepositoryNotFoundException notFound) {
err.append("error: Project ").append(name).append(" not found\n"); err.append("error: Project ").append(name).append(" not found\n");
} catch (IOException e) { } catch (IOException | ConfigInvalidException e) {
final String msg = "Cannot update project " + name;
log.error(msg, e);
err.append("error: ").append(msg).append("\n");
} catch (ConfigInvalidException e) {
final String msg = "Cannot update project " + name; final String msg = "Cannot update project " + name;
log.error(msg, e); log.error(msg, e);
err.append("error: ").append(msg).append("\n"); err.append("error: ").append(msg).append("\n");