Removed some printStackTrace in favour of throwing RuntimeExceptions. DefaultUncoughtExceptionHandler will handle them

This commit is contained in:
Federico Fissore 2015-02-23 13:33:17 +01:00
parent fe6718ce4f
commit 6007403834
9 changed files with 70 additions and 85 deletions

View File

@ -166,8 +166,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
return getUpdatedCellComponent(value, true, row); return getUpdatedCellComponent(value, true, row);
} }
private Component getUpdatedCellComponent(Object value, boolean isSelected, private Component getUpdatedCellComponent(Object value, boolean isSelected, int row) {
int row) {
ContributedLibraryReleases releases = (ContributedLibraryReleases) value; ContributedLibraryReleases releases = (ContributedLibraryReleases) value;
ContributedLibrary selectedLib = releases.getSelected(); ContributedLibrary selectedLib = releases.getSelected();
ContributedLibrary installedLib = releases.getInstalled(); ContributedLibrary installedLib = releases.getInstalled();
@ -245,7 +244,6 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
description.setText(desc); description.setText(desc);
description.setBackground(Color.WHITE); description.setBackground(Color.WHITE);
try {
// for modelToView to work, the text area has to be sized. It doesn't // for modelToView to work, the text area has to be sized. It doesn't
// matter if it's visible or not. // matter if it's visible or not.
@ -258,13 +256,13 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
description.setPreferredSize(minimalSize); description.setPreferredSize(minimalSize);
description.setSize(minimalSize); description.setSize(minimalSize);
Rectangle r = description.modelToView(description.getDocument() try {
.getLength()); Rectangle r = description.modelToView(description.getDocument().getLength());
r.height += description.modelToView(0).y; // add margins r.height += description.modelToView(0).y; // add margins
Dimension d = new Dimension(minimalSize.width, r.y + r.height); Dimension d = new Dimension(minimalSize.width, r.y + r.height);
description.setPreferredSize(d); description.setPreferredSize(d);
} catch (BadLocationException e) { } catch (BadLocationException e) {
e.printStackTrace(); throw new RuntimeException(e);
} }
if (isSelected) { if (isSelected) {

View File

@ -137,8 +137,7 @@ public class LibraryManagerUI extends InstallerJDialog {
installer.updateIndex(); installer.updateIndex();
onIndexesUpdated(); onIndexesUpdated();
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }
@ -156,8 +155,7 @@ public class LibraryManagerUI extends InstallerJDialog {
installer.install(lib); installer.install(lib);
getContribModel().updateLibrary(lib); getContribModel().updateLibrary(lib);
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }
@ -175,8 +173,7 @@ public class LibraryManagerUI extends InstallerJDialog {
installer.remove(lib); installer.remove(lib);
getContribModel().updateLibrary(lib); getContribModel().updateLibrary(lib);
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }

View File

@ -136,8 +136,7 @@ public class ContributionManagerUI extends InstallerJDialog {
installer.updateIndex(); installer.updateIndex();
onIndexesUpdated(); onIndexesUpdated();
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }
@ -157,8 +156,7 @@ public class ContributionManagerUI extends InstallerJDialog {
installer.remove(platformToRemove); installer.remove(platformToRemove);
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }
@ -175,8 +173,7 @@ public class ContributionManagerUI extends InstallerJDialog {
setProgressVisible(true); setProgressVisible(true);
installer.remove(platform); installer.remove(platform);
} catch (Exception e) { } catch (Exception e) {
// TODO Show ERROR throw new RuntimeException(e);
e.printStackTrace();
} finally { } finally {
setProgressVisible(false); setProgressVisible(false);
} }

View File

@ -64,7 +64,7 @@ public class AStyle implements Tool {
try { try {
formatterConfiguration = FileUtils.readFileToString(formatterConf); formatterConfiguration = FileUtils.readFileToString(formatterConf);
} catch (IOException e) { } catch (IOException e) {
// noop // ignored
} }
this.formatterConfiguration = formatterConfiguration; this.formatterConfiguration = formatterConfiguration;
} }

View File

@ -162,7 +162,7 @@ public class ContributionInstaller {
try { try {
destFolder.getParentFile().delete(); destFolder.getParentFile().delete();
} catch (SecurityException e) { } catch (SecurityException e) {
// Do nothing // ignore
} }
} }
} }

View File

@ -28,7 +28,13 @@
*/ */
package cc.arduino.packages.contributions; package cc.arduino.packages.contributions;
import static processing.app.helpers.filefilters.OnlyDirs.ONLY_DIRS; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
import processing.app.debug.TargetPlatformException;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -39,14 +45,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import processing.app.debug.TargetPackage; import static processing.app.helpers.filefilters.OnlyDirs.ONLY_DIRS;
import processing.app.debug.TargetPlatform;
import processing.app.debug.TargetPlatformException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
public class ContributionsIndexer { public class ContributionsIndexer {
@ -173,7 +172,7 @@ public class ContributionsIndexer {
return index.toString(); return index.toString();
} }
public List<TargetPackage> createTargetPackages() { public List<TargetPackage> createTargetPackages() throws TargetPlatformException {
List<TargetPackage> res = new ArrayList<TargetPackage>(); List<TargetPackage> res = new ArrayList<TargetPackage>();
for (ContributedPackage pack : index.getPackages()) { for (ContributedPackage pack : index.getPackages()) {
@ -187,14 +186,9 @@ public class ContributionsIndexer {
String arch = platform.getArchitecture(); String arch = platform.getArchitecture();
File folder = platform.getInstalledFolder(); File folder = platform.getInstalledFolder();
try {
TargetPlatform targetPlatform; TargetPlatform targetPlatform;
targetPlatform = new ContributedTargetPlatform(arch, folder, targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage, index);
targetPackage, index);
targetPackage.addPlatform(targetPlatform); targetPackage.addPlatform(targetPlatform);
} catch (TargetPlatformException e) {
e.printStackTrace();
}
} }
if (targetPackage.hasPlatforms()) if (targetPackage.hasPlatforms())

View File

@ -29,27 +29,15 @@
package cc.arduino.packages.security; package cc.arduino.packages.security;
import java.io.BufferedReader; import cc.arduino.packages.security.keys.PackagersPublicKeys;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.Security;
import org.bouncycastle.bcpg.ArmoredInputStream; import org.bouncycastle.bcpg.ArmoredInputStream;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPObjectFactory; import org.bouncycastle.openpgp.*;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureList;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
import processing.app.helpers.StringUtils; import processing.app.helpers.StringUtils;
import cc.arduino.packages.security.keys.PackagersPublicKeys;
import java.io.*;
import java.security.Security;
public class ClearSignedVerifier { public class ClearSignedVerifier {
@ -62,10 +50,8 @@ public class ClearSignedVerifier {
/** /**
* Verify a PGP clearText-signature. * Verify a PGP clearText-signature.
* *
* @param signedTextFile * @param signedTextFile A File containing the clearText signature
* A File containing the clearText signature * @param pubKeyRing A public key-ring containing the public key needed for the
* @param pubKeyRing
* A public key-ring containing the public key needed for the
* signature verification * signature verification
* @return A VerifyResult class with the clearText and the signature * @return A VerifyResult class with the clearText and the signature
* verification status * verification status
@ -136,7 +122,7 @@ public class ClearSignedVerifier {
try { try {
in.close(); in.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); // ignored
} }
} }
return result; return result;

View File

@ -719,6 +719,8 @@ public class BaseNoGui {
initParameters(args); initParameters(args);
init(args); init(args);
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
} }
static public void onBoardOrPortChange() { static public void onBoardOrPortChange() {
@ -765,7 +767,7 @@ public class BaseNoGui {
populateImportToLibraryTable(); populateImportToLibraryTable();
} }
static protected void loadContributedHardware(ContributionsIndexer indexer) { static protected void loadContributedHardware(ContributionsIndexer indexer) throws TargetPlatformException {
for (TargetPackage pack : indexer.createTargetPackages()) { for (TargetPackage pack : indexer.createTargetPackages()) {
packages.put(pack.getId(), pack); packages.put(pack.getId(), pack);
} }

View File

@ -0,0 +1,11 @@
package processing.app;
public class DefaultUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
System.out.println(t);
System.out.println(e);
}
}