Skip to content

Commit 0b09a8e

Browse files
committed
Adding custom error messages for some 1.0 changes.
Also, changing the logic of the code a bit to correctly place errors even when substituting custom error messages.
1 parent 7128952 commit 0b09a8e

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

app/src/processing/app/debug/Compiler.java

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,28 +380,60 @@ public void message(String s) {
380380
// }
381381

382382
if (pieces != null) {
383-
RunnerException e = sketch.placeException(pieces[3], pieces[1], PApplet.parseInt(pieces[2]) - 1);
384-
385-
// replace full file path with the name of the sketch tab (unless we're
386-
// in verbose mode, in which case don't modify the compiler output)
387-
if (e != null && !verbose) {
388-
SketchCode code = sketch.getCode(e.getCodeIndex());
389-
String fileName = code.isExtension(sketch.getDefaultExtension()) ? code.getPrettyName() : code.getFileName();
390-
s = fileName + ":" + e.getCodeLine() + ": error: " + e.getMessage();
391-
}
383+
String error = pieces[3], msg = "";
392384

393385
if (pieces[3].trim().equals("SPI.h: No such file or directory")) {
394-
e = new RunnerException("Please import the SPI library from the Sketch > Import Library menu.");
395-
s += "\nAs of Arduino 0019, the Ethernet library depends on the SPI library." +
396-
"\nYou appear to be using it or another library that depends on the SPI library.";
386+
error = "Please import the SPI library from the Sketch > Import Library menu.";
387+
msg = "\nAs of Arduino 0019, the Ethernet library depends on the SPI library." +
388+
"\nYou appear to be using it or another library that depends on the SPI library.\n\n";
397389
}
398390

399391
if (pieces[3].trim().equals("'BYTE' was not declared in this scope")) {
400-
e = new RunnerException("The 'BYTE' keyword is no longer supported.");
401-
s += "\nAs of Arduino 1.0, the 'BYTE' keyword is no longer supported." +
402-
"\nPlease use Serial.write() instead.";
392+
error = "The 'BYTE' keyword is no longer supported.";
393+
msg = "\nAs of Arduino 1.0, the 'BYTE' keyword is no longer supported." +
394+
"\nPlease use Serial.write() instead.\n\n";
395+
}
396+
397+
if (pieces[3].trim().equals("no matching function for call to 'Server::Server(int)'")) {
398+
error = "The Server class has been renamed EthernetServer.";
399+
msg = "\nAs of Arduino 1.0, the Server class in the Ethernet library " +
400+
"has been renamed to EthernetServer.\n\n";
401+
}
402+
403+
if (pieces[3].trim().equals("no matching function for call to 'Client::Client(byte [4], int)'")) {
404+
error = "The Client class has been renamed EthernetClient.";
405+
msg = "\nAs of Arduino 1.0, the Client class in the Ethernet library " +
406+
"has been renamed to EthernetClient.\n\n";
407+
}
408+
409+
if (pieces[3].trim().equals("'Udp' was not declared in this scope")) {
410+
error = "The Udp class has been renamed EthernetUdp.";
411+
msg = "\nAs of Arduino 1.0, the Udp class in the Ethernet library " +
412+
"has been renamed to EthernetClient.\n\n";
413+
}
414+
415+
if (pieces[3].trim().equals("'class TwoWire' has no member named 'send'")) {
416+
error = "Wire.send() has been renamed Wire.write().";
417+
msg = "\nAs of Arduino 1.0, the Wire.send() function was renamed " +
418+
"to Wire.write() for consistency with other libraries.\n\n";
403419
}
404420

421+
if (pieces[3].trim().equals("'class TwoWire' has no member named 'receive'")) {
422+
error = "Wire.receive() has been renamed Wire.read().";
423+
msg = "\nAs of Arduino 1.0, the Wire.receive() function was renamed " +
424+
"to Wire.read() for consistency with other libraries.\n\n";
425+
}
426+
427+
RunnerException e = sketch.placeException(error, pieces[1], PApplet.parseInt(pieces[2]) - 1);
428+
429+
// replace full file path with the name of the sketch tab (unless we're
430+
// in verbose mode, in which case don't modify the compiler output)
431+
if (e != null && !verbose) {
432+
SketchCode code = sketch.getCode(e.getCodeIndex());
433+
String fileName = code.isExtension(sketch.getDefaultExtension()) ? code.getPrettyName() : code.getFileName();
434+
s = fileName + ":" + e.getCodeLine() + ": error: " + pieces[3] + msg;
435+
}
436+
405437
if (exception == null && e != null) {
406438
exception = e;
407439
exception.hideStackTrace();

0 commit comments

Comments
 (0)