File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -2688,6 +2688,7 @@ const EasyCoder_Core = {
2688
2688
} ,
2689
2689
2690
2690
get : ( program , value ) => {
2691
+ let content = `` ;
2691
2692
switch ( value . type ) {
2692
2693
case `boolean` :
2693
2694
return {
@@ -2959,16 +2960,19 @@ const EasyCoder_Core = {
2959
2960
const property = program . getValue ( value . property ) ;
2960
2961
const propertyRecord = program . getSymbolRecord ( value . symbol ) ;
2961
2962
let propertyContent = program . getValue ( propertyRecord . value [ propertyRecord . index ] ) ;
2962
- let content = `` ;
2963
2963
if ( property && propertyContent ) {
2964
2964
if ( typeof propertyContent === `object` ) {
2965
2965
content = propertyContent [ property ] ;
2966
2966
} else if ( [ `{` , `]` ] . includes ( propertyContent . charAt ( 0 ) ) ) {
2967
2967
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 ] ;
2970
2974
} catch ( err ) {
2971
- console . log ( `Can't parse '${ propertyContent } ': ${ err . message } `) ;
2975
+ program . runtimeError ( program [ program . pc ] . lino , `Property '${ property } ' does not exist `) ;
2972
2976
}
2973
2977
}
2974
2978
}
Original file line number Diff line number Diff line change @@ -2688,6 +2688,7 @@ const EasyCoder_Core = {
2688
2688
} ,
2689
2689
2690
2690
get : ( program , value ) => {
2691
+ let content = `` ;
2691
2692
switch ( value . type ) {
2692
2693
case `boolean` :
2693
2694
return {
@@ -2959,16 +2960,19 @@ const EasyCoder_Core = {
2959
2960
const property = program . getValue ( value . property ) ;
2960
2961
const propertyRecord = program . getSymbolRecord ( value . symbol ) ;
2961
2962
let propertyContent = program . getValue ( propertyRecord . value [ propertyRecord . index ] ) ;
2962
- let content = `` ;
2963
2963
if ( property && propertyContent ) {
2964
2964
if ( typeof propertyContent === `object` ) {
2965
2965
content = propertyContent [ property ] ;
2966
2966
} else if ( [ `{` , `]` ] . includes ( propertyContent . charAt ( 0 ) ) ) {
2967
2967
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 ] ;
2970
2974
} catch ( err ) {
2971
- console . log ( `Can't parse '${ propertyContent } ': ${ err . message } `) ;
2975
+ program . runtimeError ( program [ program . pc ] . lino , `Property '${ property } ' does not exist `) ;
2972
2976
}
2973
2977
}
2974
2978
}
You can’t perform that action at this time.
0 commit comments