本文整理汇总了C#中ScriptExecutionContext.PerformMessageDecorationBeforeUnwind方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptExecutionContext.PerformMessageDecorationBeforeUnwind方法的具体用法?C# ScriptExecutionContext.PerformMessageDecorationBeforeUnwind怎么用?C# ScriptExecutionContext.PerformMessageDecorationBeforeUnwind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptExecutionContext
的用法示例。
在下文中一共展示了ScriptExecutionContext.PerformMessageDecorationBeforeUnwind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetErrorHandlerStrategy
private static DynValue SetErrorHandlerStrategy(string funcName,
ScriptExecutionContext executionContext,
CallbackArguments args,
DynValue handlerBeforeUnwind)
{
var v = args[0];
var a = new DynValue[args.Count - 1];
for (var i = 1; i < args.Count; i++)
a[i - 1] = args[i];
if (args[0].Type == DataType.ClrFunction)
{
try
{
var ret = args[0].Callback.Invoke(executionContext, a);
if (ret.Type == DataType.TailCallRequest)
{
if (ret.TailCallData.Continuation != null || ret.TailCallData.ErrorHandler != null)
throw new ScriptRuntimeException(
"the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.",
funcName);
return DynValue.NewTailCallReq(new TailCallData
{
Args = ret.TailCallData.Args,
Function = ret.TailCallData.Function,
Continuation = new CallbackFunction(pcall_continuation, funcName),
ErrorHandler = new CallbackFunction(pcall_onerror, funcName),
ErrorHandlerBeforeUnwind = handlerBeforeUnwind
});
}
if (ret.Type == DataType.YieldRequest)
{
throw new ScriptRuntimeException(
"the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.",
funcName);
}
return DynValue.NewTupleNested(DynValue.True, ret);
}
catch (ScriptRuntimeException ex)
{
executionContext.PerformMessageDecorationBeforeUnwind(handlerBeforeUnwind, ex);
return DynValue.NewTupleNested(DynValue.False, DynValue.NewString(ex.DecoratedMessage));
}
}
if (args[0].Type != DataType.Function)
{
return DynValue.NewTupleNested(DynValue.False,
DynValue.NewString("attempt to " + funcName + " a non-function"));
}
return DynValue.NewTailCallReq(new TailCallData
{
Args = a,
Function = v,
Continuation = new CallbackFunction(pcall_continuation, funcName),
ErrorHandler = new CallbackFunction(pcall_onerror, funcName),
ErrorHandlerBeforeUnwind = handlerBeforeUnwind
});
}