mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 02:45:36 +01:00
improve error messages when contrib items are incompatible
This commit is contained in:
@@ -30,6 +30,7 @@ import javax.swing.SwingWorker;
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
import processing.app.Language;
|
||||
import processing.core.PApplet;
|
||||
|
||||
|
||||
public class ContributionManager {
|
||||
@@ -176,13 +177,24 @@ public class ContributionManager {
|
||||
}
|
||||
contribZip.delete();
|
||||
|
||||
//} catch (NoClassDefFoundError ncdfe) {
|
||||
} catch (Exception e) {
|
||||
// Hiding stack trace. The error message ought to suffice.
|
||||
// e.printStackTrace();
|
||||
status
|
||||
.setErrorMessage(Language
|
||||
.interpolate("contrib.errors.download_and_install",
|
||||
ad.getName()));
|
||||
String msg = null;
|
||||
if (e instanceof RuntimeException) {
|
||||
Throwable cause = ((RuntimeException) e).getCause();
|
||||
if (cause instanceof NoClassDefFoundError ||
|
||||
cause instanceof NoSuchMethodError) {
|
||||
msg = "This item is not compatible with this version of Processing";
|
||||
} else if (cause instanceof UnsupportedClassVersionError) {
|
||||
msg = "This item needs to be recompiled for Java " +
|
||||
PApplet.javaVersionShort;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == null) {
|
||||
msg = Language.interpolate("contrib.errors.download_and_install", ad.getName());
|
||||
}
|
||||
status.setErrorMessage(msg);
|
||||
downloadProgress.cancel();
|
||||
installProgress.cancel();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,11 @@ public class ModeContribution extends LocalContribution {
|
||||
} catch (Throwable err) {
|
||||
// Throwable to catch Exceptions or UnsupportedClassVersionError et al
|
||||
if (searchName == null) {
|
||||
err.printStackTrace();
|
||||
//err.printStackTrace(System.out);
|
||||
// for 3.0b1, pass this through to the Contribution Manager so that
|
||||
// we can provide better error messages
|
||||
throw new RuntimeException(err);
|
||||
|
||||
} else {
|
||||
// For the built-in modes, don't print the exception, just log it
|
||||
// for debugging. This should be impossible for most users to reach,
|
||||
|
||||
@@ -102,25 +102,28 @@ import processing.opengl.*;
|
||||
* than working around legacy Java code.
|
||||
*/
|
||||
public class PApplet implements PConstants {
|
||||
/**
|
||||
* Full name of the Java version (i.e. 1.5.0_11).
|
||||
*/
|
||||
public static final String javaVersionName =
|
||||
/** Full name of the Java version (i.e. 1.5.0_11). */
|
||||
static public final String javaVersionName =
|
||||
System.getProperty("java.version");
|
||||
|
||||
/** Short name of Java version, i.e. 1.8. */
|
||||
static public final String javaVersionShort =
|
||||
javaVersionName.substring(0, javaVersionName.indexOf("_"));
|
||||
|
||||
/**
|
||||
* Version of Java that's in use, whether 1.1 or 1.3 or whatever,
|
||||
* stored as a float.
|
||||
* <p>
|
||||
* Note that because this is stored as a float, the values may
|
||||
* not be <EM>exactly</EM> 1.3 or 1.4. Instead, make sure you're
|
||||
* comparing against 1.3f or 1.4f, which will have the same amount
|
||||
* of error (i.e. 1.40000001). This could just be a double, but
|
||||
* since Processing only uses floats, it's safer for this to be a float
|
||||
* because specifying a double with the preprocessor is awkward.
|
||||
* Note that because this is stored as a float, the values may not be
|
||||
* <EM>exactly</EM> 1.3 or 1.4. The PDE will make 1.8 or whatever into
|
||||
* a float automatically, so outside the PDE, make sure you're comparing
|
||||
* against 1.3f or 1.4f, which will have the same amount of error
|
||||
* (i.e. 1.40000001). This could just be a double, but since Processing
|
||||
* only uses floats, it's safer as a float because specifying a double
|
||||
* (with this narrow case especially) with the preprocessor is awkward.
|
||||
*/
|
||||
public static final float javaVersion =
|
||||
new Float(javaVersionName.substring(0, 3)).floatValue();
|
||||
new Float(javaVersionShort).floatValue();
|
||||
|
||||
/**
|
||||
* Current platform in use, one of the
|
||||
|
||||
Reference in New Issue
Block a user