Skip to content

Commit 8cac77b

Browse files
committed
Improve error display logic:
1. Don't try to highlight errors without location info. 2. Don't show the "Compiling" message.
1 parent e76f9cd commit 8cac77b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

web/js/codeworld.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ function initCodeworld() {
388388

389389
if (request.status === 400 || request.status === 200) {
390390
const messages = parseCompileErrors(request.responseText);
391-
callback(messages);
391+
callback(messages.filter((msg) => msg.from && msg.to));
392392
} else if (request.status === 0) {
393393
// Request was cancelled because of a later change. Do nothing.
394394
} else {

web/js/codeworld_shared.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,8 @@ function parseCompileErrors(rawErrors) {
20432043
.join('\n');
20442044
const re1 = /^program\.hs:(\d+):((\d+)-?(\d+)?): (\w+):(.*)/;
20452045
const re2 = /^program\.hs:\((\d+),(\d+)\)-\((\d+),(\d+)\): (\w+):(.*)/;
2046-
const reLink = /: Linking program[.]jsexe.*/;
2046+
const reCompile = /: \[[0-9]+ of [0-9]+\] Compiling .*/;
2047+
const reLink = /: Linking program[.]jsexe\b.*/;
20472048

20482049
if (err.trim() === '') {
20492050
// Ignore empty messages.
@@ -2100,7 +2101,7 @@ function parseCompileErrors(rawErrors) {
21002101
fullText: err,
21012102
message: (match[6] ? `${match[6].trim()}\n` : '') + otherLines,
21022103
});
2103-
} else if (!reLink.test(firstLine)) {
2104+
} else if (!reCompile.test(firstLine) && !reLink.test(firstLine)) {
21042105
errors.push({
21052106
fullText: err,
21062107
message: err,

0 commit comments

Comments
 (0)