-
here are my codes public static readonly Dictionary<string, JsValue> VariablesExportedDict = new();
// export private variables for other engine calling
public static void Export(string key, JsValue jsValue)
{
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
throw new ArgumentException(nameof(key));
}
if (VariablesExportedDict.ContainsKey(key))
{
lock (VariablesExportedDict)
{
VariablesExportedDict[key] = jsValue;
}
}
else
{
VariablesExportedDict.Add(key, jsValue);
}
} // a.js
serein.export('test', (x) => { serein.log(x) }); // export a function // b.js
try {
serein.import('test')(1)
} catch (e) {
serein.log(e);
} If the engine for But the Jint.Runtime.ExecutionCanceledException: The script execution was canceled.
在 Jint.Runtime.ExceptionHelper.ThrowExecutionCanceledException()
在 Jint.Constraints.CancellationConstraint.Check()
在 Jint.Engine.RunBeforeExecuteStatementChecks(Statement statement)
在 Jint.Runtime.Interpreter.JintStatementList.Execute(EvaluationContext context)
在 Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArgument, JsValue[] arguments)
在 Jint.Runtime.Interpreter.Expressions.JintCallExpression.EvaluateInternal(EvaluationContext context)
在 Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue(EvaluationContext context)
在 Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArgument, JsValue[] arguments)
在 Jint.Engine.<>c__DisplayClass93_0.<Invoke>g__DoInvoke|0()
在 Jint.Engine.ExecuteWithConstraints[T](Boolean strict, Func`1 callback)
在 Serein.Core.JSPlugin.JSFunc.<>c__DisplayClass5_0.<SetTimer>b__0(Object _, ElapsedEventArgs _) 位置 C:\GitHub\Serein\Serein\Universal\Core\JSPlugin\JSFunc.cs:行号 159 As I expect, the engine should catch it and convert it into js error which should be caught. Is it a bug or a feature specially designed? Looking forward to your reply :D |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
You need to configure engine's options Lines 291 to 297 in 8b0da8a |
Beta Was this translation helpful? Give feedback.
-
Which runtime are you using at this time and how are you referencing |
Beta Was this translation helpful? Give feedback.
You need to configure engine's options
ExceptionHandler
.jint/Jint/Options.cs
Lines 291 to 297 in 8b0da8a