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

View File

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

View File

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

View File

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

View File

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