예제 #1
0
        internal static void SetErrorVariables(IScriptExtent extent, RuntimeException rte, ExecutionContext context, Pipe outputPipe)
        {
            string    newValue       = null;
            Exception innerException = rte;
            int       num            = 0;

            while ((innerException != null) && (num++ < 10))
            {
                if (!string.IsNullOrEmpty(innerException.StackTrace))
                {
                    newValue = innerException.StackTrace;
                }
                innerException = innerException.InnerException;
            }
            context.SetVariable(SpecialVariables.StackTraceVarPath, newValue);
            InterpreterError.UpdateExceptionErrorRecordPosition(rte, extent);
            ErrorRecord record = rte.ErrorRecord.WrapException(rte);

            if (!(rte is PipelineStoppedException))
            {
                if (outputPipe != null)
                {
                    outputPipe.AppendVariableList(VariableStreamKind.Error, record);
                }
                context.AppendDollarError(record);
            }
        }