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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,13 @@
*/
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.FileInputStream;
@ -39,14 +45,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import processing.app.debug.TargetPackage;
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;
import static processing.app.helpers.filefilters.OnlyDirs.ONLY_DIRS;
public class ContributionsIndexer {
@ -173,7 +172,7 @@ public class ContributionsIndexer {
return index.toString();
}
public List<TargetPackage> createTargetPackages() {
public List<TargetPackage> createTargetPackages() throws TargetPlatformException {
List<TargetPackage> res = new ArrayList<TargetPackage>();
for (ContributedPackage pack : index.getPackages()) {
@ -187,14 +186,9 @@ public class ContributionsIndexer {
String arch = platform.getArchitecture();
File folder = platform.getInstalledFolder();
try {
TargetPlatform targetPlatform;
targetPlatform = new ContributedTargetPlatform(arch, folder,
targetPackage, index);
targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage, index);
targetPackage.addPlatform(targetPlatform);
} catch (TargetPlatformException e) {
e.printStackTrace();
}
}
if (targetPackage.hasPlatforms())

View File

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

View File

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