File tree Expand file tree Collapse file tree 4 files changed +24
-4
lines changed
JavaScriptEngineSwitcher.ChakraCore
JavaScriptEngineSwitcher.Jint
JavaScriptEngineSwitcher.Jurassic
JavaScriptEngineSwitcher.V8 Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 4
4
using System . Linq ;
5
5
using System . Reflection ;
6
6
using System . Runtime . InteropServices ;
7
+ using System . Text . RegularExpressions ;
7
8
8
9
using OriginalJsException = JavaScriptEngineSwitcher . ChakraCore . JsRt . JsException ;
9
10
@@ -32,6 +33,13 @@ public sealed class ChakraCoreJsEngine : JsEngineBase
32
33
/// </summary>
33
34
private const string EngineVersion = "1.4.1" ;
34
35
36
+ /// <summary>
37
+ /// Regular expression for working with the string representation of error
38
+ /// </summary>
39
+ private static readonly Regex _errorStringRegex =
40
+ new Regex ( @"[ ]{3,5}at (?:[A-Za-z_\$][0-9A-Za-z_\$ ]* )?" +
41
+ @"\([^\s*?""<>|][^\t\n\r*?""<>|]*?:(?<lineNumber>\d+):(?<columnNumber>\d+)\)" ) ;
42
+
35
43
/// <summary>
36
44
/// Instance of JS runtime
37
45
/// </summary>
@@ -917,6 +925,18 @@ private static JsRuntimeException ConvertJsExceptionToJsRuntimeException(
917
925
columnNumber = columnPropertyValue . ConvertToNumber ( ) . ToInt32 ( ) + 1 ;
918
926
}
919
927
928
+ if ( lineNumber <= 0 && columnNumber <= 0 )
929
+ {
930
+ Match errorStringMatch = _errorStringRegex . Match ( message ) ;
931
+ if ( errorStringMatch . Success )
932
+ {
933
+ GroupCollection errorStringGroups = errorStringMatch . Groups ;
934
+
935
+ lineNumber = int . Parse ( errorStringGroups [ "lineNumber" ] . Value ) ;
936
+ columnNumber = int . Parse ( errorStringGroups [ "columnNumber" ] . Value ) ;
937
+ }
938
+ }
939
+
920
940
JsPropertyId sourcePropertyId = JsPropertyId . FromString ( "source" ) ;
921
941
if ( errorValue . HasProperty ( sourcePropertyId ) )
922
942
{
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ private JsRuntimeException ConvertJavaScriptExceptionToJsRuntimeException(
172
172
{
173
173
string category = string . Empty ;
174
174
int lineNumber = jsException . LineNumber ;
175
- int columnNumber = jsException . Column ;
175
+ int columnNumber = jsException . Column + 1 ;
176
176
string message = jsException . Message ;
177
177
OriginalJsValue errorValue = jsException . Error ;
178
178
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ private JsRuntimeException ConvertJavascriptExceptionToJsRuntimeException(
170
170
Category = jsException . Name ,
171
171
LineNumber = jsException . LineNumber ,
172
172
ColumnNumber = 0 ,
173
- SourceFragment = jsException . SourcePath
173
+ SourceFragment = string . Empty
174
174
} ;
175
175
176
176
return jsRuntimeException ;
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ public sealed class V8JsEngine : JsEngineBase
48
48
/// Regular expression for working with the string representation of error
49
49
/// </summary>
50
50
private static readonly Regex _errorStringRegex =
51
- new Regex ( @"at (?:[A-Za-z_\$][0-9A-Za-z_\$]* )?" +
52
- @"\(?Script Document(?: \s*\[(temp|\d+)\]) ?:(?<lineNumber>\d+):(?<columnNumber>\d+)\)?" ) ;
51
+ new Regex ( @"[ ]{3,5} at (?:[A-Za-z_\$][0-9A-Za-z_\$]* )?" +
52
+ @"\(?[^ \s*?""<>|][^\t\n\r*?""<>|]* ?:(?<lineNumber>\d+):(?<columnNumber>\d+)\)? -> " ) ;
53
53
54
54
/// <summary>
55
55
/// Synchronizer of code execution
You can’t perform that action at this time.
0 commit comments