more bulletproofing around bad modes

This commit is contained in:
Ben Fry
2015-06-08 15:51:12 -04:00
parent 39a1a4fda5
commit 676de0aa38
2 changed files with 25 additions and 3 deletions

View File

@@ -788,16 +788,29 @@ public class Base {
}
// Editor.State state = new Editor.State(editors);
Editor editor = nextMode.createEditor(this, path, state);
Editor editor = null;
try {
editor = nextMode.createEditor(this, path, state);
} catch (NoSuchMethodError nsme) {
Base.showWarning("Mode out of date",
nextMode.getTitle() + " is not compatible with this version of Processing.\n" +
"Try updating the Mode or contact its author for a new version.", nsme);
} catch (Throwable t) {
showBadnessTrace("Mode Problems",
"A nasty error occurred while trying to use " + nextMode.getTitle() + ".\n" +
"It may not be compatible with this version of Processing.\n" +
"Try updating the Mode or contact its author for a new version.", t, false);
}
if (editor == null) {
// if it's not mode[0] already, then don't go into an infinite loop
// if the bad mode is the default mode, don't go into an infinite loop
// trying to recreate a window with the default mode.
Mode defaultMode = getDefaultMode();
if (nextMode == defaultMode) {
Base.showError("Editor Problems",
"An error occurred while trying to change modes.\n" +
"We'll have to quit for now because it's an\n" +
"unfortunate bit of indigestion.",
"unfortunate bit of indigestion with the default Mode.",
null);
} else {
editor = defaultMode.createEditor(this, path, state);
@@ -820,6 +833,9 @@ public class Base {
return editor;
// } catch (NoSuchMethodError nsme) {
// Base.showWarning(title, message);
} catch (Throwable t) {
showBadnessTrace("Terrible News",
"A serious error occurred while " +

View File

@@ -126,6 +126,12 @@ public class ModeContribution extends LocalContribution {
if (!existing.containsKey(folder)) {
try {
contribModes.add(new ModeContribution(base, folder, null));
} catch (NoSuchMethodError nsme) {
System.err.println(folder.getName() + " contains an incompatible Mode");
System.err.println(nsme.getMessage());
} catch (NoClassDefFoundError ncdfe) {
System.err.println(folder.getName() + " contains an incompatible Mode");
System.err.println(ncdfe.getMessage());
} catch (IgnorableException ig) {
Base.log(ig.getMessage());
} catch (Throwable e) {