@@ -49,7 +49,7 @@ public sealed class YantraJsEngine : JsEngineBase
4949 /// <summary>
5050 /// Version of original JS engine
5151 /// </summary>
52- private const string EngineVersion = "1.2.218 " ;
52+ private const string EngineVersion = "1.2.225 " ;
5353
5454 /// <summary>
5555 /// Regular expression for working with the error message
@@ -324,20 +324,12 @@ private WrapperException WrapJsException(OriginalException originalException)
324324 int . Parse ( messageGroups [ "columnNumber" ] . Value ) : 0 ;
325325 }
326326
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- }
327+ string messageWithCallStack = type == JsErrorType . Syntax ?
328+ originalException . JSStackTrace . AsStringOrDefault ( )
329+ :
330+ errorValue . Stack ?? errorValue [ "stack" ] . AsStringOrDefault ( )
331+ ;
332+ string rawCallStack = GetRawCallStack ( message , messageWithType , messageWithCallStack ) ;
341333
342334 callStackItems = YantraJsErrorHelpers . ParseErrorLocation ( rawCallStack ) ;
343335 callStackItems = YantraJsErrorHelpers . FilterErrorLocationItems ( callStackItems ) ;
@@ -396,6 +388,17 @@ private WrapperException WrapJsException(OriginalException originalException)
396388 return wrapperException ;
397389 }
398390
391+ private static string GetRawCallStack ( string message , string messageWithType , string messageWithCallStack )
392+ {
393+ string baseMessage = messageWithCallStack . StartsWith ( messageWithType ) ? messageWithType : message ;
394+ string rawCallStack = messageWithCallStack
395+ . TrimStart ( baseMessage )
396+ . TrimStart ( new char [ ] { '\n ' , '\r ' } )
397+ ;
398+
399+ return rawCallStack ;
400+ }
401+
399402 private void OnConsoleWrite ( OriginalContext context , string type , in OriginalArguments args )
400403 {
401404 int argCount = args . Length ;
0 commit comments