1212using OriginalClrType = YantraJS . Core . Clr . ClrType ;
1313using OriginalContext = YantraJS . Core . JSContext ;
1414using OriginalDate = YantraJS . Core . JSDate ;
15+ using OriginalError = YantraJS . Core . JSError ;
1516using OriginalException = YantraJS . Core . JSException ;
1617using OriginalFunction = YantraJS . Core . JSFunction ;
1718using OriginalJsonObject = YantraJS . Core . JSJSON ;
2122
2223using JavaScriptEngineSwitcher . Core ;
2324using JavaScriptEngineSwitcher . Core . Constants ;
25+ using JavaScriptEngineSwitcher . Core . Extensions ;
2426using JavaScriptEngineSwitcher . Core . Helpers ;
2527using JavaScriptEngineSwitcher . Core . Utilities ;
2628
@@ -47,7 +49,7 @@ public sealed class YantraJsEngine : JsEngineBase
4749 /// <summary>
4850 /// Version of original JS engine
4951 /// </summary>
50- private const string EngineVersion = "1.2.209 " ;
52+ private const string EngineVersion = "1.2.218 " ;
5153
5254 /// <summary>
5355 /// Regular expression for working with the error message
@@ -305,11 +307,11 @@ private WrapperException WrapJsException(OriginalException originalException)
305307 int columnNumber = 0 ;
306308 ErrorLocationItem [ ] callStackItems = null ;
307309
308- OriginalValue errorValue = originalException . Error ;
310+ var errorValue = originalException . Error as OriginalError ;
309311 if ( errorValue != null )
310312 {
311- message = errorValue . ToString ( ) ;
312- Match messageMatch = _errorMessageRegex . Match ( message ) ;
313+ string messageWithType = errorValue . ToString ( ) ;
314+ Match messageMatch = _errorMessageRegex . Match ( messageWithType ) ;
313315
314316 if ( messageMatch . Success )
315317 {
@@ -322,7 +324,20 @@ private WrapperException WrapJsException(OriginalException originalException)
322324 int . Parse ( messageGroups [ "columnNumber" ] . Value ) : 0 ;
323325 }
324326
325- string rawCallStack = errorValue [ "stack" ] . AsStringOrDefault ( ) ;
327+ string rawCallStack ;
328+
329+ if ( type == JsErrorType . Syntax )
330+ {
331+ rawCallStack = originalException . JSStackTrace . AsStringOrDefault ( ) ;
332+ }
333+ else
334+ {
335+ string messageWithTypeAndCallStack = errorValue . Stack ?? errorValue [ "stack" ] . AsStringOrDefault ( ) ;
336+ rawCallStack = messageWithTypeAndCallStack
337+ . TrimStart ( messageWithType )
338+ . TrimStart ( new char [ ] { '\n ' , '\r ' } )
339+ ;
340+ }
326341
327342 callStackItems = YantraJsErrorHelpers . ParseErrorLocation ( rawCallStack ) ;
328343 callStackItems = YantraJsErrorHelpers . FilterErrorLocationItems ( callStackItems ) ;
0 commit comments