@@ -24,7 +24,7 @@ class JSLEvaluator {
24
24
case ASTIntegerLiteral :
25
25
return this . evaluateIntegerExpression ( node as ASTIntegerLiteral ) ;
26
26
default :
27
- throw `${ node . tokenLiteral ( ) } node evaluation not supported` ;
27
+ throw new Error ( `${ node . tokenLiteral ( ) } node evaluation not supported` ) ;
28
28
}
29
29
}
30
30
@@ -39,7 +39,7 @@ class JSLEvaluator {
39
39
private evaluateExpressionStatement ( statement : ASTExpressionStatement , json : any ) : any {
40
40
const expression = statement . expression ;
41
41
if ( ! expression ) {
42
- throw `Expression: ${ statement . toString ( ) } not found` ;
42
+ throw new Error ( `Expression: ${ statement . toString ( ) } not found` ) ;
43
43
}
44
44
45
45
return this . evaluate ( json , expression ) ;
@@ -49,12 +49,12 @@ class JSLEvaluator {
49
49
50
50
private evaluateSelectExpression ( expression : ASTSelectExpression , json : any ) : any {
51
51
if ( typeof json !== 'object' ) {
52
- throw `Invalid nested key sequence ${ expression . key } ` ;
52
+ throw new Error ( `Invalid nested key sequence ${ expression . key } ` ) ;
53
53
}
54
54
55
55
const key : string = expression . key ;
56
56
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 } ` ) ;
58
58
}
59
59
60
60
return json [ key ] ;
@@ -64,7 +64,7 @@ class JSLEvaluator {
64
64
const left = expression . left ;
65
65
const index = expression . index ;
66
66
if ( ! left || ! index ) {
67
- throw `Expression: ${ expression . toString ( ) } not found` ;
67
+ throw new Error ( `Expression: ${ expression . toString ( ) } not found` ) ;
68
68
}
69
69
70
70
const arr : any = this . evaluate ( json , left ) ;
@@ -73,7 +73,7 @@ class JSLEvaluator {
73
73
return arr [ idx ] ;
74
74
}
75
75
76
- throw `cannot subscript at ${ expression . toString ( ) } [${ idx } ]` ;
76
+ throw new Error ( `cannot subscript at ${ expression . toString ( ) } [${ idx } ]` ) ;
77
77
}
78
78
79
79
private evaluateIntegerExpression ( expression : ASTIntegerLiteral ) : number {
0 commit comments