Skip to content

Commit b49533c

Browse files
committed
In JsRT modes now script error contains a full stack trace
1 parent a70d086 commit b49533c

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

NuGet/MsieJavaScriptEngine.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>This library is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine). Project was based on the code of SassAndCoffee.JavaScript (http://github.com/paulcbetts/SassAndCoffee), Chakra Sample Hosts (http://github.com/panopticoncentral/chakra-host) and jsrt-dotnet (http://github.com/robpaveza/jsrt-dotnet).</description>
1414
<summary>This library is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine).</summary>
15-
<releaseNotes>Added support of .NET Core 1.0.4.</releaseNotes>
15+
<releaseNotes>1. Added support of .NET Core 1.0.4;
16+
2. In JsRT modes now script error contains a full stack trace.</releaseNotes>
1617
<copyright>Copyright (c) 2012-2017 Andrey Taritsyn - http://www.taritsyn.ru</copyright>
1718
<language>en-US</language>
1819
<tags>JavaScript ECMAScript MSIE IE Edge Chakra</tags>

NuGet/readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
=============
2222
RELEASE NOTES
2323
=============
24-
Added support of .NET Core 1.0.4.
24+
1. Added support of .NET Core 1.0.4;
25+
2. In JsRT modes now script error contains a full stack trace.
2526

2627
============
2728
PROJECT SITE

src/MsieJavaScriptEngine/JsRt/Edge/ChakraEdgeJsRtJsEngine.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,20 @@ private JsRuntimeException ConvertJsExceptionToJsRuntimeException(
824824
category = "Script error";
825825
EdgeJsValue errorValue = jsScriptException.Error;
826826

827-
EdgeJsPropertyId messagePropertyId = EdgeJsPropertyId.FromString("message");
828-
EdgeJsValue messagePropertyValue = errorValue.GetProperty(messagePropertyId);
829-
string scriptMessage = messagePropertyValue.ConvertToString().ToString();
830-
if (!string.IsNullOrWhiteSpace(scriptMessage))
827+
EdgeJsPropertyId stackPropertyId = EdgeJsPropertyId.FromString("stack");
828+
if (errorValue.HasProperty(stackPropertyId))
831829
{
832-
message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
830+
EdgeJsValue stackPropertyValue = errorValue.GetProperty(stackPropertyId);
831+
message = stackPropertyValue.ConvertToString().ToString();
832+
}
833+
else
834+
{
835+
EdgeJsValue messagePropertyValue = errorValue.GetProperty("message");
836+
string scriptMessage = messagePropertyValue.ConvertToString().ToString();
837+
if (!string.IsNullOrWhiteSpace(scriptMessage))
838+
{
839+
message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
840+
}
833841
}
834842

835843
EdgeJsPropertyId linePropertyId = EdgeJsPropertyId.FromString("line");

src/MsieJavaScriptEngine/JsRt/Ie/ChakraIeJsRtJsEngine.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,20 @@ private JsRuntimeException ConvertJsExceptionToJsRuntimeException(
847847
category = "Script error";
848848
IeJsValue errorValue = jsScriptException.Error;
849849

850-
IeJsPropertyId messagePropertyId = IeJsPropertyId.FromString("message");
851-
IeJsValue messagePropertyValue = errorValue.GetProperty(messagePropertyId);
852-
string scriptMessage = messagePropertyValue.ConvertToString().ToString();
853-
if (!string.IsNullOrWhiteSpace(scriptMessage))
850+
IeJsPropertyId stackPropertyId = IeJsPropertyId.FromString("stack");
851+
if (errorValue.HasProperty(stackPropertyId))
854852
{
855-
message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
853+
IeJsValue stackPropertyValue = errorValue.GetProperty(stackPropertyId);
854+
message = stackPropertyValue.ConvertToString().ToString();
855+
}
856+
else
857+
{
858+
IeJsValue messagePropertyValue = errorValue.GetProperty("message");
859+
string scriptMessage = messagePropertyValue.ConvertToString().ToString();
860+
if (!string.IsNullOrWhiteSpace(scriptMessage))
861+
{
862+
message = string.Format("{0}: {1}", message.TrimEnd('.'), scriptMessage);
863+
}
856864
}
857865

858866
IeJsPropertyId linePropertyId = IeJsPropertyId.FromString("line");

0 commit comments

Comments
 (0)