Simplify some catch logic

This commit is contained in:
Daniel Martí 2015-04-15 17:56:40 +02:00
parent 13c9a14a50
commit 2365d314c6
5 changed files with 7 additions and 61 deletions

View File

@ -636,9 +636,7 @@ public class UpdateService extends IntentService implements ProgressListener {
Log.d(TAG, "Updating/inserting " + operations.size() + " apps.");
try {
executeBatchWithStatus(AppProvider.getAuthority(), operations, currentCount, totalUpdateCount);
} catch (RemoteException e) {
Log.e(TAG, e.getMessage());
} catch (OperationApplicationException e) {
} catch (RemoteException | OperationApplicationException e) {
Log.e(TAG, e.getMessage());
}
}
@ -702,9 +700,7 @@ public class UpdateService extends IntentService implements ProgressListener {
Log.d(TAG, "Updating/inserting " + operations.size() + " apks.");
try {
executeBatchWithStatus(ApkProvider.getAuthority(), operations, currentCount, totalApksAppsCount);
} catch (RemoteException e) {
Log.e(TAG, e.getMessage());
} catch (OperationApplicationException e) {
} catch (RemoteException | OperationApplicationException e) {
Log.e(TAG, e.getMessage());
}
}

View File

@ -155,22 +155,7 @@ public class LocalRepoKeyStore {
keyManagers = new KeyManager[] {
wrappedKeyManager
};
} catch (UnrecoverableKeyException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (KeyStoreException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (CertificateException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (OperatorCreationException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (IOException e) {
} catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException | CertificateException | OperatorCreationException | IOException e) {
Log.e(TAG, "Error loading keystore: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
}
@ -222,28 +207,7 @@ public class LocalRepoKeyStore {
zipSigner.setKeys("kerplapp", cert, priv, DEFAULT_SIG_ALG, null);
zipSigner.signZip(input.getAbsolutePath(), output.getAbsolutePath());
} catch (ClassNotFoundException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (IllegalAccessException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (InstantiationException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (KeyStoreException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (UnrecoverableKeyException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (IOException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (GeneralSecurityException e) {
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | GeneralSecurityException | IOException e) {
Log.e(TAG, "Unable to sign local repo index: " + e);
Log.e(TAG, Log.getStackTraceString(e));
}
@ -273,13 +237,7 @@ public class LocalRepoKeyStore {
Key key = keyStore.getKey(INDEX_CERT_ALIAS, "".toCharArray());
if (key instanceof PrivateKey)
return keyStore.getCertificate(INDEX_CERT_ALIAS);
} catch (KeyStoreException e) {
Log.e(TAG, "Unable to get certificate for local repo: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (UnrecoverableKeyException e) {
Log.e(TAG, "Unable to get certificate for local repo: " + e);
Log.e(TAG, Log.getStackTraceString(e));
} catch (NoSuchAlgorithmException e) {
} catch (GeneralSecurityException e) {
Log.e(TAG, "Unable to get certificate for local repo: " + e);
Log.e(TAG, Log.getStackTraceString(e));
}

View File

@ -180,8 +180,6 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener {
dlWrapper.download();
return true;
} catch (MalformedURLException e) {
onErrorDownloading(e.getLocalizedMessage());
} catch (IOException e) {
onErrorDownloading(e.getLocalizedMessage());
}

View File

@ -154,10 +154,7 @@ public class LocalHTTPD extends NanoHTTPD {
localRepoKeyStore.getKeyStore(),
localRepoKeyStore.getKeyManagers());
makeSecure(factory);
} catch (IOException e) {
Log.e(TAG, "Could not enable HTTPS: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
} catch (LocalRepoKeyStore.InitException e) {
} catch (LocalRepoKeyStore.InitException | IOException e) {
Log.e(TAG, "Could not enable HTTPS: " + e.getMessage());
Log.e(TAG, Log.getStackTraceString(e));
}

View File

@ -45,10 +45,7 @@ public class SignedRepoUpdaterTest extends InstrumentationTestCase {
assertTrue(testFile.length() == simpleIndexXml.length());
assertEquals(FileUtils.readFileToString(testFile),
FileUtils.readFileToString(simpleIndexXml));
} catch (IOException e) {
e.printStackTrace();
fail();
} catch (UpdateException e) {
} catch (IOException | UpdateException e) {
e.printStackTrace();
fail();
}