While working on a testing framework that executes JavaScript tests, I wanted to have ClearScript tell me the location of the syntax errors it found. It doesn't.
This is in a non-browser environment. I thought version 5.4.1 would fix it. It doesn't.
A colleague debugged the DLL and discovered that the GetDetails() method in the WindowsScriptEngine class (WindowsScriptEngine.Site.cs) will return either a stackTrace or an error location but not both.
The answer was to rework the try block to be:
try
This is in a non-browser environment. I thought version 5.4.1 would fix it. It doesn't.
A colleague debugged the DLL and discovered that the GetDetails() method in the WindowsScriptEngine class (WindowsScriptEngine.Site.cs) will return either a stackTrace or an error location but not both.
The answer was to rework the try block to be:
try
{
var errorLocation = GetErrorLocation(error);
if (!string.IsNullOrWhiteSpace(errorLocation))
{
message += "\n" + errorLocation;
}
var stackTrace = engine.GetStackTraceInternal();
if (!string.IsNullOrWhiteSpace(stackTrace))
{
message += "\n" + stackTrace;
}
return message;
}
Now it returns both in one message.