本文整理汇总了C#中Microsoft.Scripting.Interpreter.InterpretedFrame.SaveTraceToException方法的典型用法代码示例。如果您正苦于以下问题:C# InterpretedFrame.SaveTraceToException方法的具体用法?C# InterpretedFrame.SaveTraceToException怎么用?C# InterpretedFrame.SaveTraceToException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Interpreter.InterpretedFrame
的用法示例。
在下文中一共展示了InterpretedFrame.SaveTraceToException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(InterpretedFrame frame) {
while (true) {
try {
var instructions = _instructions.Instructions;
int index = frame.InstructionIndex;
while (index < instructions.Length) {
index += instructions[index].Run(frame);
frame.InstructionIndex = index;
}
return;
} catch (Exception exception) {
frame.SaveTraceToException(exception);
frame.FaultingInstruction = frame.InstructionIndex;
ExceptionHandler handler;
frame.InstructionIndex += GotoHandler(frame, exception, out handler);
if (handler == null || handler.IsFault) {
// run finally/fault blocks:
Run(frame);
// a finally block can throw an exception caught by a handler, which cancels the previous exception:
if (frame.InstructionIndex == RethrowOnReturn) {
throw;
}
return;
}
// stay in the current catch so that ThreadAbortException is not rethrown by CLR:
var abort = exception as ThreadAbortException;
if (abort != null) {
_anyAbortException = abort;
frame.CurrentAbortHandler = handler;
Run(frame);
return;
}
exception = null;
}
}
}
示例2: HandleException
private ExceptionHandlingResult HandleException(InterpretedFrame frame, Exception exception) {
frame.SaveTraceToException(exception);
ExceptionHandler handler;
frame.InstructionIndex += GotoHandler(frame, exception, out handler);
if (handler == null || handler.IsFault) {
// run finally/fault blocks:
Run(frame);
// a finally block can throw an exception caught by a handler, which cancels the previous exception:
if (frame.InstructionIndex == RethrowOnReturn) {
return ExceptionHandlingResult.Rethrow;
}
return ExceptionHandlingResult.Return;
}
#if FEATURE_THREAD
// stay in the current catch so that ThreadAbortException is not rethrown by CLR:
var abort = exception as ThreadAbortException;
if (abort != null) {
_anyAbortException = abort;
frame.CurrentAbortHandler = handler;
}
#endif
while (true) {
try {
var instructions = _instructions.Instructions;
int index = frame.InstructionIndex;
while (index < instructions.Length) {
var curInstr = instructions[index];
index += curInstr.Run(frame);
frame.InstructionIndex = index;
if (curInstr is LeaveExceptionHandlerInstruction) {
// we've completed handling of this exception
return ExceptionHandlingResult.Continue;
}
}
if (frame.InstructionIndex == RethrowOnReturn) {
return ExceptionHandlingResult.Rethrow;
}
return ExceptionHandlingResult.Return;
} catch (Exception nestedException) {
switch (HandleException(frame, nestedException)) {
case ExceptionHandlingResult.Rethrow: throw;
case ExceptionHandlingResult.Continue: continue;
case ExceptionHandlingResult.Return: return ExceptionHandlingResult.Return;
default: throw Assert.Unreachable;
}
}
}
}