Skip to content

Commit

Permalink
Playground: ensure compiler exception are shown
Browse files Browse the repository at this point in the history
if the line numbers reported are wrong, the editor errors might not be shown.
Brian J. Cardiff committed Aug 14, 2016
1 parent 2751252 commit aa7a7ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compiler/crystal/tools/playground/public/session.js
Original file line number Diff line number Diff line change
@@ -340,16 +340,20 @@ Playground.Session = function(options) {
case "exception":
this._triggerFinish();

var last_line = this.editor.lastLine() + 1;
this._fullError = message.exception.message;
if (message.exception.payload) {
for (var i = 0; i < message.exception.payload.length; i++) {
var ex = message.exception.payload[i];
if (ex.file == "play" || ex.file == "") {
this._showEditorError(ex.line, ex.column, ex.message, i);
// if there is an issue with the reported line,
// let's make sure the error is displayed
var ex_line = Math.min(ex.line, last_line);
this._showEditorError(ex_line, ex.column, ex.message, i);
}
}
} else {
this._showEditorError(this.editor.lastLine(), 1, "Compiler error", 0);
this._showEditorError(last_line, 1, "Compiler error", 0);
}
break;
case "bug":

0 comments on commit aa7a7ea

Please sign in to comment.