Skip to content

Commit 3d4b026

Browse files
Preserve "fatal" in compiler errors
When transforming compiler errors (to make filenames more friendly), it would match "fatal error" or "error" but then always reconstruct as "error", modifying the compiler error in a way that is not intended. This commit fixes that, as well as the previous hardcoding of the "error: " prefix when rebuilding the error message, by capturing this entire prefix and simply reproducing it in the resulting error message.
1 parent e387c23 commit 3d4b026

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arduino-core/src/cc/arduino/Compiler.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ enum BuilderAction {
134134
}
135135
}
136136

137-
private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*(fatal)?\\s*error:\\s*(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL);
137+
private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*((fatal)?\\s*error:\\s*)(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL);
138138

139139
private final File pathToSketch;
140140
private final Sketch sketch;
@@ -522,7 +522,8 @@ public void message(String s) {
522522
if (pieces[3] != null) {
523523
col = PApplet.parseInt(pieces[3].substring(1));
524524
}
525-
String error = pieces[5];
525+
String errorPrefix = pieces[4];
526+
String error = pieces[6];
526527

527528
if (error.trim().equals("SPI.h: No such file or directory")) {
528529
error = tr("Please import the SPI library from the Sketch > Import Library menu.");
@@ -583,7 +584,7 @@ public void message(String s) {
583584
int lineNum = ex.getCodeLine() + 1;
584585
int colNum = ex.getCodeColumn();
585586
String column = (colNum != -1) ? (":" + colNum) : "";
586-
s = fileName + ":" + lineNum + column + ": error: " + error + msg;
587+
s = fileName + ":" + lineNum + column + ": " + errorPrefix + error + msg;
587588
}
588589

589590
if (ex != null) {

0 commit comments

Comments
 (0)