Skip to content

Commit 4e05566

Browse files
committed
Bug fix attempt
1 parent 17e979c commit 4e05566

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

dist/easycoder.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,7 @@ const EasyCoder_Core = {
26882688
},
26892689

26902690
get: (program, value) => {
2691+
let content = ``;
26912692
switch (value.type) {
26922693
case `boolean`:
26932694
return {
@@ -2959,16 +2960,19 @@ const EasyCoder_Core = {
29592960
const property = program.getValue(value.property);
29602961
const propertyRecord = program.getSymbolRecord(value.symbol);
29612962
let propertyContent = program.getValue(propertyRecord.value[propertyRecord.index]);
2962-
let content = ``;
29632963
if (property && propertyContent) {
29642964
if (typeof propertyContent === `object`) {
29652965
content = propertyContent[property];
29662966
} else if ([`{`, `]`].includes(propertyContent.charAt(0))) {
29672967
try {
2968-
let c = JSON.parse(propertyContent);
2969-
content = c[property];
2968+
content = JSON.parse(propertyContent);
2969+
} catch (err) {
2970+
program.runtimeError(program[program.pc].lino, `Can't parse '${propertyContent}': ${err.message}`);
2971+
}
2972+
try {
2973+
content = content[property];
29702974
} catch (err) {
2971-
console.log(`Can't parse '${propertyContent}': ${err.message}`);
2975+
program.runtimeError(program[program.pc].lino, `Property '${property}' does not exist`);
29722976
}
29732977
}
29742978
}

js/easycoder/Core.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,7 @@ const EasyCoder_Core = {
26882688
},
26892689

26902690
get: (program, value) => {
2691+
let content = ``;
26912692
switch (value.type) {
26922693
case `boolean`:
26932694
return {
@@ -2959,16 +2960,19 @@ const EasyCoder_Core = {
29592960
const property = program.getValue(value.property);
29602961
const propertyRecord = program.getSymbolRecord(value.symbol);
29612962
let propertyContent = program.getValue(propertyRecord.value[propertyRecord.index]);
2962-
let content = ``;
29632963
if (property && propertyContent) {
29642964
if (typeof propertyContent === `object`) {
29652965
content = propertyContent[property];
29662966
} else if ([`{`, `]`].includes(propertyContent.charAt(0))) {
29672967
try {
2968-
let c = JSON.parse(propertyContent);
2969-
content = c[property];
2968+
content = JSON.parse(propertyContent);
2969+
} catch (err) {
2970+
program.runtimeError(program[program.pc].lino, `Can't parse '${propertyContent}': ${err.message}`);
2971+
}
2972+
try {
2973+
content = content[property];
29702974
} catch (err) {
2971-
console.log(`Can't parse '${propertyContent}': ${err.message}`);
2975+
program.runtimeError(program[program.pc].lino, `Property '${property}' does not exist`);
29722976
}
29732977
}
29742978
}

0 commit comments

Comments
 (0)