SaveTraceToException() private method

private SaveTraceToException ( Exception exception ) : void
exception Exception
return void
コード例 #1
0
        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
0
ファイル: Interpreter.cs プロジェクト: rudimk/dlr-dotnet
        private ExceptionHandlingResult HandleException(InterpretedFrame frame, 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)
                {
                    return(ExceptionHandlingResult.Rethrow);
                }
                return(ExceptionHandlingResult.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;
            }

            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;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Interpreter.cs プロジェクト: kevinkeeney/ironruby
        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;
                }
            }
        }
コード例 #4
0
ファイル: Interpreter.cs プロジェクト: Jaykul/IronLangs
        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;
                    }
                }
            }
        }