@@ -24,7 +24,7 @@ class JSLEvaluator {
2424 case ASTIntegerLiteral :
2525 return this . evaluateIntegerExpression ( node as ASTIntegerLiteral ) ;
2626 default :
27- throw `${ node . tokenLiteral ( ) } node evaluation not supported` ;
27+ throw new Error ( `${ node . tokenLiteral ( ) } node evaluation not supported` ) ;
2828 }
2929 }
3030
@@ -39,7 +39,7 @@ class JSLEvaluator {
3939 private evaluateExpressionStatement ( statement : ASTExpressionStatement , json : any ) : any {
4040 const expression = statement . expression ;
4141 if ( ! expression ) {
42- throw `Expression: ${ statement . toString ( ) } not found` ;
42+ throw new Error ( `Expression: ${ statement . toString ( ) } not found` ) ;
4343 }
4444
4545 return this . evaluate ( json , expression ) ;
@@ -49,12 +49,12 @@ class JSLEvaluator {
4949
5050 private evaluateSelectExpression ( expression : ASTSelectExpression , json : any ) : any {
5151 if ( typeof json !== 'object' ) {
52- throw `Invalid nested key sequence ${ expression . key } ` ;
52+ throw new Error ( `Invalid nested key sequence ${ expression . key } ` ) ;
5353 }
5454
5555 const key : string = expression . key ;
5656 if ( ! json . hasOwnProperty ( key ) ) {
57- throw `Key not found in the json: ${ expression . key } ` ;
57+ throw new Error ( `Key not found in the json: ${ expression . key } ` ) ;
5858 }
5959
6060 return json [ key ] ;
@@ -64,7 +64,7 @@ class JSLEvaluator {
6464 const left = expression . left ;
6565 const index = expression . index ;
6666 if ( ! left || ! index ) {
67- throw `Expression: ${ expression . toString ( ) } not found` ;
67+ throw new Error ( `Expression: ${ expression . toString ( ) } not found` ) ;
6868 }
6969
7070 const arr : any = this . evaluate ( json , left ) ;
@@ -73,7 +73,7 @@ class JSLEvaluator {
7373 return arr [ idx ] ;
7474 }
7575
76- throw `cannot subscript at ${ expression . toString ( ) } [${ idx } ]` ;
76+ throw new Error ( `cannot subscript at ${ expression . toString ( ) } [${ idx } ]` ) ;
7777 }
7878
7979 private evaluateIntegerExpression ( expression : ASTIntegerLiteral ) : number {
0 commit comments