Skip to content

Commit 3fa06df

Browse files
authored
Merge pull request #131 from easycoder/dev
Fix bug in error reporting
2 parents 88406eb + 1c4a8c5 commit 3fa06df

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

dist/easycoder-min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8095,8 +8095,11 @@ const EasyCoder = {
80958095
tokens,
80968096
scriptLines
80978097
} = source ? source : program.source;
8098-
const lino = this.compiling ? tokens[EasyCoder_Compiler.getIndex()].lino : program[program.pc].lino;
8099-
var errString = (this.compiling ? `Compile` : `Runtime`) + ` error in '${program.script}'`;
8098+
const compiler = EasyCoder_Compiler;
8099+
const lino = this.compiling ? tokens[compiler.getIndex()].lino : program[program.pc].lino;
8100+
var errString = this.compiling
8101+
? `Compile error in '${compiler.script}'`
8102+
: `Runtime error in '${program.script}'`;
81008103
errString += `:\n`;
81018104
var start = lino - 5;
81028105
start = start < 0 ? 0 : start;
@@ -8105,7 +8108,7 @@ const EasyCoder = {
81058108
errString += nn + ` ` + scriptLines[n].line.split(`\\s`).join(` `) + `\n`;
81068109
}
81078110
errString += `${err.message}\n`;
8108-
const warnings = EasyCoder_Compiler.getWarnings();
8111+
const warnings = compiler.getWarnings();
81098112
if (warnings.length) {
81108113
errString += `Warnings:\n`;
81118114
for (const warning of warnings) {

js/easycoder/Main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ const EasyCoder = {
4343
tokens,
4444
scriptLines
4545
} = source ? source : program.source;
46-
const lino = this.compiling ? tokens[EasyCoder_Compiler.getIndex()].lino : program[program.pc].lino;
47-
var errString = (this.compiling ? `Compile` : `Runtime`) + ` error in '${program.script}'`;
46+
const compiler = EasyCoder_Compiler;
47+
const lino = this.compiling ? tokens[compiler.getIndex()].lino : program[program.pc].lino;
48+
var errString = this.compiling
49+
? `Compile error in '${compiler.script}'`
50+
: `Runtime error in '${program.script}'`;
4851
errString += `:\n`;
4952
var start = lino - 5;
5053
start = start < 0 ? 0 : start;
@@ -53,7 +56,7 @@ const EasyCoder = {
5356
errString += nn + ` ` + scriptLines[n].line.split(`\\s`).join(` `) + `\n`;
5457
}
5558
errString += `${err.message}\n`;
56-
const warnings = EasyCoder_Compiler.getWarnings();
59+
const warnings = compiler.getWarnings();
5760
if (warnings.length) {
5861
errString += `Warnings:\n`;
5962
for (const warning of warnings) {

0 commit comments

Comments
 (0)