mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
lots of fixes to error handling
This commit is contained in:
+2
-2
@@ -260,14 +260,14 @@ public class Compiler implements MessageConsumer {
|
||||
if (fileIndex == 0) { // main class, figure out which tab
|
||||
for (int i = 1; i < sketch.codeCount; i++) {
|
||||
if (sketch.code[i].flavor == Sketch.PDE) {
|
||||
if (sketch.code[i].lineOffset < lineNumber) {
|
||||
if (sketch.code[i].preprocOffset < lineNumber) {
|
||||
fileIndex = i;
|
||||
//System.out.println("i'm thinkin file " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fileIndex != 0) { // if found another culprit
|
||||
lineNumber -= sketch.code[fileIndex].lineOffset;
|
||||
lineNumber -= sketch.code[fileIndex].preprocOffset;
|
||||
//System.out.println("i'm sayin line " + lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ public class EditorConsole extends JScrollPane {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Base.showWarning("Console Error",
|
||||
"A problem occurred while trying to open the\n" +
|
||||
"files used to store the console output.", e);
|
||||
"A problem occurred while trying to open the\n" +
|
||||
"files used to store the console output.", e);
|
||||
}
|
||||
|
||||
consoleOut =
|
||||
@@ -171,6 +171,7 @@ public class EditorConsole extends JScrollPane {
|
||||
|
||||
|
||||
public void message(String what, boolean err, boolean advance) {
|
||||
//public void message(String what, boolean err, boolean advance) {
|
||||
// under osx, suppress the spew about the serial port
|
||||
// to avoid an error every time someone loads their app
|
||||
// (the error is dealt with in Base with a message dialog)
|
||||
@@ -184,8 +185,10 @@ public class EditorConsole extends JScrollPane {
|
||||
|
||||
if (err) {
|
||||
systemErr.print(what);
|
||||
//systemErr.print("CE" + what);
|
||||
} else {
|
||||
systemOut.print(what);
|
||||
//systemOut.print("CO" + what);
|
||||
}
|
||||
|
||||
if (advance) {
|
||||
@@ -205,13 +208,13 @@ public class EditorConsole extends JScrollPane {
|
||||
|
||||
/**
|
||||
* append a piece of text to the console.
|
||||
*
|
||||
* <P>
|
||||
* Swing components are NOT thread-safe, and since the MessageSiphon
|
||||
* instantiates new threads, and in those callbacks, they often print
|
||||
* output to stdout and stderr, which are wrapped by EditorConsoleStream
|
||||
* and eventually leads to EditorConsole.appendText(), which directly
|
||||
* updates the Swing text components, causing deadlock.
|
||||
*
|
||||
* <P>
|
||||
* A quick hack from Francis Li (who found this to be a problem)
|
||||
* wraps the contents of appendText() into a Runnable and uses
|
||||
* SwingUtilities.invokeLater() to ensure that the updates only
|
||||
@@ -275,7 +278,7 @@ class EditorConsoleStream extends OutputStream {
|
||||
OutputStream echo;
|
||||
|
||||
public EditorConsoleStream(EditorConsole parent,
|
||||
boolean err, OutputStream echo) {
|
||||
boolean err, OutputStream echo) {
|
||||
this.parent = parent;
|
||||
this.err = err;
|
||||
this.echo = echo;
|
||||
|
||||
+40
-15
@@ -347,8 +347,10 @@ public class Runner implements MessageConsumer {
|
||||
|
||||
// made synchronized for rev 87
|
||||
synchronized public void message(String s) {
|
||||
if (s.trim().length() == 0) return;
|
||||
//System.out.println("M" + s.length() + ":" + s);
|
||||
//System.out.println("M" + s.length() + ":" + s.trim()); // + "MMM" + s.length());
|
||||
|
||||
// this eats the CRLFs on the lines.. oops.. do it later
|
||||
//if (s.trim().length() == 0) return;
|
||||
|
||||
// this is PApplet sending a message (via System.out.println)
|
||||
// that signals that the applet has been quit.
|
||||
@@ -394,9 +396,9 @@ public class Runner implements MessageConsumer {
|
||||
//System.err.println("[" + s.length() + "] " + s);
|
||||
System.err.flush();
|
||||
|
||||
// if s.length <=2, ignore it because that probably means
|
||||
// that it's just the platform line-terminators.
|
||||
//if (s.length() < 2) return;
|
||||
// exit here because otherwise the exception name
|
||||
// may be titled with a blank string
|
||||
if (s.trim().length() == 0) return;
|
||||
|
||||
// annoying, because it seems as though the terminators
|
||||
// aren't being sent properly
|
||||
@@ -441,7 +443,7 @@ java.lang.NullPointerException
|
||||
String pkgClassFxn = null;
|
||||
//String fileLine = null;
|
||||
int codeIndex = -1;
|
||||
int lineIndex = -1;
|
||||
int lineNumber = -1;
|
||||
|
||||
if (startParen == -1) {
|
||||
pkgClassFxn = s;
|
||||
@@ -450,7 +452,11 @@ java.lang.NullPointerException
|
||||
pkgClassFxn = s.substring(0, startParen);
|
||||
// "(javatest.java:5)"
|
||||
String fileAndLine = s.substring(startParen + 1);
|
||||
fileAndLine = fileAndLine.substring(0, fileAndLine.length() - 1);
|
||||
int stopParen = fileAndLine.indexOf(')');
|
||||
//fileAndLine = fileAndLine.substring(0, fileAndLine.length() - 1);
|
||||
fileAndLine = fileAndLine.substring(0, stopParen);
|
||||
//System.out.println("file 'n line " + fileAndLine);
|
||||
|
||||
//if (!fileAndLine.equals("Unknown Source")) {
|
||||
// "javatest.java:5"
|
||||
int colonIndex = fileAndLine.indexOf(':');
|
||||
@@ -459,27 +465,46 @@ java.lang.NullPointerException
|
||||
// "javatest.java" and "5"
|
||||
//System.out.println("filename = " + filename);
|
||||
//System.out.println("pre0 = " + sketch.code[0].preprocName);
|
||||
//for (int i = 0; i < sketch.codeCount; i++) {
|
||||
//System.out.println(i + " " + sketch.code[i].lineOffset + " " +
|
||||
// sketch.code[i].preprocName);
|
||||
//}
|
||||
lineNumber =
|
||||
Integer.parseInt(fileAndLine.substring(colonIndex + 1)) - 1;
|
||||
|
||||
for (int i = 0; i < sketch.codeCount; i++) {
|
||||
if (sketch.code[i].preprocName.equals(filename)) {
|
||||
SketchCode code = sketch.code[i];
|
||||
//System.out.println(code.preprocName + " " + lineNumber + " " +
|
||||
// code.preprocOffset);
|
||||
if (((code.preprocName == null) &&
|
||||
(lineNumber >= code.preprocOffset)) ||
|
||||
((code.preprocName != null) &&
|
||||
code.preprocName.equals(filename))) {
|
||||
codeIndex = i;
|
||||
break;
|
||||
//System.out.println("got codeindex " + codeIndex);
|
||||
//break;
|
||||
//} else if (
|
||||
}
|
||||
}
|
||||
// in case this was a tab that got embedded into the main .java
|
||||
lineNumber -= sketch.code[codeIndex].preprocOffset;
|
||||
|
||||
if (codeIndex != -1) {
|
||||
// this may have a paren on the end, if so need to strip
|
||||
// down to just the digits
|
||||
/*
|
||||
int lastNumberIndex = colonIndex + 1;
|
||||
while ((lastNumberIndex < fileAndLine.length()) &&
|
||||
Character.isDigit(fileAndLine.charAt(lastNumberIndex))) {
|
||||
lastNumberIndex++;
|
||||
}
|
||||
// lineIndex is 1-indexed, but editor wants zero-indexed
|
||||
lineIndex =
|
||||
Integer.parseInt(fileAndLine.substring(colonIndex + 1,
|
||||
lastNumberIndex));
|
||||
*/
|
||||
|
||||
// lineNumber is 1-indexed, but editor wants zero-indexed
|
||||
// getMessage() will be what's shown in the editor
|
||||
exception =
|
||||
new RunnerException(exception.getMessage(),
|
||||
codeIndex, lineIndex - 1, -1);
|
||||
codeIndex, lineNumber, -1);
|
||||
exception.hideStackTrace = true;
|
||||
foundMessageSource = true;
|
||||
}
|
||||
@@ -529,7 +554,7 @@ java.lang.NullPointerException
|
||||
// because of the line that comes after
|
||||
*/
|
||||
|
||||
} else if (messageLineCount > 5) {
|
||||
} else if (messageLineCount > 10) { // 5 -> 10 for 0088
|
||||
// this means the class name may not be mentioned
|
||||
// in the stack trace.. this is just a general purpose
|
||||
// error, but needs to make it through anyway.
|
||||
|
||||
+18
-14
@@ -1260,16 +1260,20 @@ public class Sketch {
|
||||
//PApplet.printarr(codeFolderPackages);
|
||||
|
||||
} else {
|
||||
/*
|
||||
// since using the special classloader,
|
||||
// run externally whenever there are extra classes defined
|
||||
//externalRuntime = (codeCount > 1);
|
||||
// this no longer appears to be true.. so scrapping for 0088
|
||||
|
||||
// check to see if multiple files that include a .java file
|
||||
externalRuntime = false;
|
||||
for (int i = 0; i < codeCount; i++) {
|
||||
if (code[i].flavor == JAVA) externalRuntime = true;
|
||||
if (code[i].flavor == JAVA) {
|
||||
externalRuntime = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
// since using the special classloader,
|
||||
// run externally whenever there are extra classes defined
|
||||
externalRuntime = (codeCount > 1);
|
||||
|
||||
//codeFolderPackages = null;
|
||||
libraryPath = "";
|
||||
}
|
||||
@@ -1289,7 +1293,7 @@ public class Sketch {
|
||||
|
||||
for (int i = 1; i < codeCount; i++) {
|
||||
if (code[i].flavor == PDE) {
|
||||
code[i].lineOffset = ++bigCount;
|
||||
code[i].preprocOffset = ++bigCount;
|
||||
bigCode.append('\n');
|
||||
bigCode.append(code[i].program);
|
||||
bigCount += countLines(code[i].program);
|
||||
@@ -1349,11 +1353,11 @@ public class Sketch {
|
||||
int errorLine = re.getLine() - 1;
|
||||
for (int i = 1; i < codeCount; i++) {
|
||||
if ((code[i].flavor == PDE) &&
|
||||
(code[i].lineOffset < errorLine)) {
|
||||
(code[i].preprocOffset < errorLine)) {
|
||||
errorFile = i;
|
||||
}
|
||||
}
|
||||
errorLine -= code[errorFile].lineOffset;
|
||||
errorLine -= code[errorFile].preprocOffset;
|
||||
|
||||
throw new RunnerException(re.getMessage(), errorFile,
|
||||
errorLine, re.getColumn());
|
||||
@@ -1372,9 +1376,9 @@ public class Sketch {
|
||||
pattern = compiler.compile(mess);
|
||||
} catch (MalformedPatternException e) {
|
||||
Base.showWarning("Internal Problem",
|
||||
"An internal error occurred while trying\n" +
|
||||
"to compile the sketch. Please report\n" +
|
||||
"this online at http://processing.org/bugs", e);
|
||||
"An internal error occurred while trying\n" +
|
||||
"to compile the sketch. Please report\n" +
|
||||
"this online at http://processing.org/bugs", e);
|
||||
}
|
||||
|
||||
PatternMatcherInput input =
|
||||
@@ -1387,11 +1391,11 @@ public class Sketch {
|
||||
int errorFile = 0;
|
||||
for (int i = 1; i < codeCount; i++) {
|
||||
if ((code[i].flavor == PDE) &&
|
||||
(code[i].lineOffset < errorLine)) {
|
||||
(code[i].preprocOffset < errorLine)) {
|
||||
errorFile = i;
|
||||
}
|
||||
}
|
||||
errorLine -= code[errorFile].lineOffset;
|
||||
errorLine -= code[errorFile].preprocOffset;
|
||||
|
||||
throw new RunnerException(tsre.getMessage(),
|
||||
errorFile, errorLine, errorColumn);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class SketchCode {
|
||||
//SketchHistory history; // TODO add history information
|
||||
|
||||
String preprocName; // name of .java file after preproc
|
||||
int lineOffset; // where this code starts relative to the concat'd code
|
||||
int preprocOffset; // where this code starts relative to the concat'd code
|
||||
|
||||
|
||||
public SketchCode(String name, File file, int flavor) {
|
||||
|
||||
+7
-6
@@ -1026,6 +1026,7 @@ public class PApplet extends Applet
|
||||
|
||||
} else {
|
||||
//e.printStackTrace(System.out);
|
||||
//System.out.println("re-throwing");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -2381,16 +2382,16 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
static public final float ceil(float what) {
|
||||
return (float) Math.ceil(what);
|
||||
static public final int ceil(float what) {
|
||||
return (int) Math.ceil(what);
|
||||
}
|
||||
|
||||
static public final float floor(float what) {
|
||||
return (float) Math.floor(what);
|
||||
static public final int floor(float what) {
|
||||
return (int) Math.floor(what);
|
||||
}
|
||||
|
||||
static public final float round(float what) {
|
||||
return Math.round(what);
|
||||
static public final int round(float what) {
|
||||
return (int) Math.round(what);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ X bring screen space and font size settings back in to PGraphics
|
||||
X causing too much trouble to be stuck down in PFont
|
||||
X createFont crashes on verdana (win2k)
|
||||
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115258282;start=0
|
||||
X made ceil(), floor(), and round() return ints instead of floats
|
||||
|
||||
|
||||
cleared out / completed in previous releases
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
0088 pde
|
||||
X fix a problem with Runner.message() getting exceptions
|
||||
X if digits to end of text, was crashing (new digit check code)
|
||||
X if codeCount > 1 externalRuntime = true, Sketch.java line 272
|
||||
X nah, just sticking with that, runs better
|
||||
X rev 87 on linux included a version of jikes built on redhat 7.3
|
||||
_ check to make sure this still works on the fc3 box
|
||||
X check to make sure this still works on the fc3 box
|
||||
_ stick with the rh73/fc3 build, include instructions on the site
|
||||
_ maybe have the script test for jikes first?
|
||||
_ try test run, if it closes w/ an error, then show error
|
||||
|
||||
X exceptions in other tabs not comunig through
|
||||
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115415184;start=0
|
||||
|
||||
_ renaming a .java file only shows the name w/o .java
|
||||
_ which makes you rename the file to a .pde instead
|
||||
@@ -11,12 +19,10 @@ _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Collaboration;actio
|
||||
_ archive sketch not saving the entire sketch?
|
||||
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115187666;start=0
|
||||
|
||||
_ export css problem
|
||||
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115061823;start=0
|
||||
_ error messages from external not coming through very well
|
||||
_ especially on macosx.. is it writing to stdout/stderr tho?
|
||||
_ figure out why it's killing things early? the process maybe?
|
||||
|
||||
_ customizing ugly coffee cup startup crap
|
||||
_ http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/special_attributes.html
|
||||
_ http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/special_attributes.html
|
||||
|
||||
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
@@ -47,6 +53,13 @@ _ the draw() method must exist, otherwise the sketch won't run
|
||||
_ need timer in as part of the api
|
||||
_ or at least include an example that uses it
|
||||
|
||||
casey working on...
|
||||
_ export css problem
|
||||
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115061823;start=0
|
||||
_ customizing ugly coffee cup startup crap
|
||||
_ http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/special_attributes.html
|
||||
_ http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/special_attributes.html
|
||||
|
||||
_ get platform checker into the latest exhibition piece
|
||||
|
||||
_ get these two todo lists into their bugzilla categories
|
||||
@@ -94,6 +107,9 @@ _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action
|
||||
_ sun.applet.Main is appletviewer
|
||||
|
||||
_ settings.path.fallback not being used
|
||||
_ really important for intl versions that are having trouble
|
||||
_ or ask for the sketch folder name.. why isn't it?
|
||||
|
||||
_ can't find build dir on operating systems w/ non-ascii chars
|
||||
_ or rather, when user accounts have non-ascii chars in the name
|
||||
_ try setting up an account where this is the case
|
||||
@@ -595,7 +611,6 @@ _ if user cancels prompt, throws a '-128,userCanceledErr'
|
||||
_ in which case, need to return null (or ""?) for the prompt
|
||||
_ which will also just give you the last camera
|
||||
_ should it be new Camera(PROMPT);
|
||||
_ error messages from quicktime not coming through very well
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user