5
5
using IOriginalPrimitiveInstance = Jint . Native . IPrimitiveInstance ;
6
6
using OriginalEngine = Jint . Engine ;
7
7
using OriginalJavaScriptException = Jint . Runtime . JavaScriptException ;
8
- using OriginalJintException = Jint . Runtime . JintException ;
9
8
using OriginalMemoryLimitExceededException = Jint . Runtime . MemoryLimitExceededException ;
10
9
using OriginalObjectInstance = Jint . Native . Object . ObjectInstance ;
11
10
using OriginalParser = Esprima . JavaScriptParser ;
12
11
using OriginalParserException = Esprima . ParserException ;
13
12
using OriginalParserOptions = Esprima . ParserOptions ;
14
13
using OriginalProgram = Esprima . Ast . Program ;
15
14
using OriginalRecursionDepthOverflowException = Jint . Runtime . RecursionDepthOverflowException ;
15
+ using OriginalRuntimeException = Jint . Runtime . JintException ;
16
16
using OriginalStatementsCountOverflowException = Jint . Runtime . StatementsCountOverflowException ;
17
17
using OriginalTypeReference = Jint . Runtime . Interop . TypeReference ;
18
18
using OriginalTypes = Jint . Runtime . Types ;
27
27
28
28
using CoreStrings = JavaScriptEngineSwitcher . Core . Resources . Strings ;
29
29
using WrapperCompilationException = JavaScriptEngineSwitcher . Core . JsCompilationException ;
30
- using WrapperException = JavaScriptEngineSwitcher . Core . JsException ;
31
30
using WrapperRuntimeException = JavaScriptEngineSwitcher . Core . JsRuntimeException ;
32
31
using WrapperTimeoutException = JavaScriptEngineSwitcher . Core . JsTimeoutException ;
33
32
using WrapperUsageException = JavaScriptEngineSwitcher . Core . JsUsageException ;
@@ -188,24 +187,26 @@ private static WrapperCompilationException WrapParserException(OriginalParserExc
188
187
return wrapperCompilationException ;
189
188
}
190
189
191
- private static WrapperException WrapJintException (
192
- OriginalJintException originalJintException )
190
+ private static WrapperRuntimeException WrapRuntimeException ( OriginalRuntimeException originalRuntimeException )
193
191
{
194
- WrapperException wrapperException ;
195
- string message = originalJintException . Message ;
192
+ string message = originalRuntimeException . Message ;
196
193
if ( string . IsNullOrWhiteSpace ( message ) )
197
194
{
198
195
message = "An unknown error occurred" ;
199
196
}
200
197
string description = message ;
198
+ string type = string . Empty ;
199
+ string documentName = string . Empty ;
200
+ int lineNumber = 0 ;
201
+ int columnNumber = 0 ;
202
+ string callStack = string . Empty ;
201
203
202
- if ( originalJintException is OriginalJavaScriptException )
204
+ if ( originalRuntimeException is OriginalJavaScriptException )
203
205
{
204
- var originalJavaScriptException = ( OriginalJavaScriptException ) originalJintException ;
205
- string type = string . Empty ;
206
- string documentName = originalJavaScriptException . Location . Source ;
207
- int lineNumber = originalJavaScriptException . LineNumber ;
208
- int columnNumber = originalJavaScriptException . Column + 1 ;
206
+ var originalJavaScriptException = ( OriginalJavaScriptException ) originalRuntimeException ;
207
+ documentName = originalJavaScriptException . Location . Source ;
208
+ lineNumber = originalJavaScriptException . LineNumber ;
209
+ columnNumber = originalJavaScriptException . Column + 1 ;
209
210
210
211
OriginalValue errorValue = originalJavaScriptException . Error ;
211
212
if ( errorValue . IsObject ( ) )
@@ -219,46 +220,22 @@ private static WrapperException WrapJintException(
219
220
}
220
221
}
221
222
222
- if ( ! string . IsNullOrEmpty ( type ) )
223
+ if ( string . IsNullOrEmpty ( type ) )
223
224
{
224
- message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , documentName , lineNumber ,
225
- columnNumber ) ;
226
-
227
- var wrapperRuntimeException = new WrapperRuntimeException ( message , EngineName , EngineVersion ,
228
- originalJavaScriptException )
229
- {
230
- Type = type ,
231
- DocumentName = documentName ,
232
- LineNumber = lineNumber ,
233
- ColumnNumber = columnNumber
234
- } ;
235
-
236
- wrapperException = wrapperRuntimeException ;
237
- }
238
- else
239
- {
240
- wrapperException = new WrapperException ( message , EngineName , EngineVersion ,
241
- originalJavaScriptException ) ;
225
+ type = JsErrorType . Common ;
242
226
}
227
+
228
+ message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , documentName , lineNumber ,
229
+ columnNumber ) ;
243
230
}
244
- else if ( originalJintException is OriginalMemoryLimitExceededException )
231
+ else if ( originalRuntimeException is OriginalMemoryLimitExceededException )
245
232
{
246
- var originalMemoryException = ( OriginalMemoryLimitExceededException ) originalJintException ;
247
- string type = JsErrorType . Common ;
233
+ type = JsErrorType . Common ;
248
234
message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , string . Empty ) ;
249
-
250
- var wrapperRuntimeException = new WrapperRuntimeException ( message , EngineName , EngineVersion ,
251
- originalMemoryException )
252
- {
253
- Description = description
254
- } ;
255
-
256
- wrapperException = wrapperRuntimeException ;
257
235
}
258
- else if ( originalJintException is OriginalRecursionDepthOverflowException )
236
+ else if ( originalRuntimeException is OriginalRecursionDepthOverflowException )
259
237
{
260
- var originalRecursionException = ( OriginalRecursionDepthOverflowException ) originalJintException ;
261
- string callStack = string . Empty ;
238
+ var originalRecursionException = ( OriginalRecursionDepthOverflowException ) originalRuntimeException ;
262
239
string [ ] callChainItems = originalRecursionException . CallChain
263
240
. Split ( new string [ ] { "->" } , StringSplitOptions . None )
264
241
;
@@ -287,42 +264,32 @@ private static WrapperException WrapJintException(
287
264
stringBuilderPool . Return ( stackBuilder ) ;
288
265
}
289
266
290
- string type = JsErrorType . Range ;
267
+ type = JsErrorType . Range ;
291
268
message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , callStack ) ;
292
-
293
- var wrapperRuntimeException = new WrapperRuntimeException ( message , EngineName , EngineVersion ,
294
- originalRecursionException )
295
- {
296
- Description = description ,
297
- Type = type ,
298
- CallStack = callStack
299
- } ;
300
-
301
- wrapperException = wrapperRuntimeException ;
302
269
}
303
- else if ( originalJintException is OriginalStatementsCountOverflowException )
270
+ else if ( originalRuntimeException is OriginalStatementsCountOverflowException )
304
271
{
305
- var originalStatementsException = ( OriginalStatementsCountOverflowException ) originalJintException ;
306
- string type = JsErrorType . Range ;
272
+ type = JsErrorType . Range ;
307
273
message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , string . Empty ) ;
308
-
309
- var wrapperRuntimeException = new WrapperRuntimeException ( message , EngineName , EngineVersion ,
310
- originalStatementsException )
311
- {
312
- Description = description
313
- } ;
314
-
315
- wrapperException = wrapperRuntimeException ;
316
274
}
317
275
else
318
276
{
319
- wrapperException = new WrapperException ( message , EngineName , EngineVersion ,
320
- originalJintException ) ;
277
+ type = JsErrorType . Common ;
278
+ message = JsErrorHelpers . GenerateScriptErrorMessage ( type , description , string . Empty ) ;
321
279
}
322
280
323
- wrapperException . Description = description ;
281
+ var wrapperRuntimeException = new WrapperRuntimeException ( message , EngineName , EngineVersion ,
282
+ originalRuntimeException )
283
+ {
284
+ Description = description ,
285
+ Type = type ,
286
+ DocumentName = documentName ,
287
+ LineNumber = lineNumber ,
288
+ ColumnNumber = columnNumber ,
289
+ CallStack = callStack
290
+ } ;
324
291
325
- return wrapperException ;
292
+ return wrapperRuntimeException ;
326
293
}
327
294
328
295
private static WrapperTimeoutException WrapTimeoutException ( TimeoutException originalTimeoutException )
@@ -390,9 +357,9 @@ protected override object InnerEvaluate(string expression, string documentName)
390
357
{
391
358
throw WrapParserException ( e ) ;
392
359
}
393
- catch ( OriginalJintException e )
360
+ catch ( OriginalRuntimeException e )
394
361
{
395
- throw WrapJintException ( e ) ;
362
+ throw WrapRuntimeException ( e ) ;
396
363
}
397
364
catch ( TimeoutException e )
398
365
{
@@ -437,9 +404,9 @@ protected override void InnerExecute(string code, string documentName)
437
404
{
438
405
throw WrapParserException ( e ) ;
439
406
}
440
- catch ( OriginalJintException e )
407
+ catch ( OriginalRuntimeException e )
441
408
{
442
- throw WrapJintException ( e ) ;
409
+ throw WrapRuntimeException ( e ) ;
443
410
}
444
411
catch ( TimeoutException e )
445
412
{
@@ -466,9 +433,9 @@ protected override void InnerExecute(IPrecompiledScript precompiledScript)
466
433
{
467
434
_jsEngine . Execute ( jintPrecompiledScript . Program ) ;
468
435
}
469
- catch ( OriginalJintException e )
436
+ catch ( OriginalRuntimeException e )
470
437
{
471
- throw WrapJintException ( e ) ;
438
+ throw WrapRuntimeException ( e ) ;
472
439
}
473
440
catch ( TimeoutException e )
474
441
{
@@ -489,9 +456,9 @@ protected override object InnerCallFunction(string functionName, params object[]
489
456
{
490
457
functionValue = _jsEngine . GetValue ( functionName ) ;
491
458
}
492
- catch ( OriginalJintException e )
459
+ catch ( OriginalRuntimeException e )
493
460
{
494
- throw WrapJintException ( e ) ;
461
+ throw WrapRuntimeException ( e ) ;
495
462
}
496
463
497
464
OriginalValue resultValue ;
@@ -500,9 +467,9 @@ protected override object InnerCallFunction(string functionName, params object[]
500
467
{
501
468
resultValue = _jsEngine . Invoke ( functionValue , args ) ;
502
469
}
503
- catch ( OriginalJintException e )
470
+ catch ( OriginalRuntimeException e )
504
471
{
505
- throw WrapJintException ( e ) ;
472
+ throw WrapRuntimeException ( e ) ;
506
473
}
507
474
catch ( TimeoutException e )
508
475
{
@@ -559,9 +526,9 @@ protected override object InnerGetVariableValue(string variableName)
559
526
{
560
527
variableValue = _jsEngine . GetValue ( variableName ) ;
561
528
}
562
- catch ( OriginalJintException e )
529
+ catch ( OriginalRuntimeException e )
563
530
{
564
- throw WrapJintException ( e ) ;
531
+ throw WrapRuntimeException ( e ) ;
565
532
}
566
533
567
534
result = MapToHostType ( variableValue ) ;
@@ -587,9 +554,9 @@ protected override void InnerSetVariableValue(string variableName, object value)
587
554
{
588
555
_jsEngine . SetValue ( variableName , processedValue ) ;
589
556
}
590
- catch ( OriginalJintException e )
557
+ catch ( OriginalRuntimeException e )
591
558
{
592
- throw WrapJintException ( e ) ;
559
+ throw WrapRuntimeException ( e ) ;
593
560
}
594
561
}
595
562
}
@@ -609,9 +576,9 @@ protected override void InnerEmbedHostObject(string itemName, object value)
609
576
{
610
577
_jsEngine . SetValue ( itemName , processedValue ) ;
611
578
}
612
- catch ( OriginalJintException e )
579
+ catch ( OriginalRuntimeException e )
613
580
{
614
- throw WrapJintException ( e ) ;
581
+ throw WrapRuntimeException ( e ) ;
615
582
}
616
583
}
617
584
}
@@ -626,9 +593,9 @@ protected override void InnerEmbedHostType(string itemName, Type type)
626
593
{
627
594
_jsEngine . SetValue ( itemName , typeReference ) ;
628
595
}
629
- catch ( OriginalJintException e )
596
+ catch ( OriginalRuntimeException e )
630
597
{
631
- throw WrapJintException ( e ) ;
598
+ throw WrapRuntimeException ( e ) ;
632
599
}
633
600
}
634
601
}
0 commit comments