Exemple #1
0
        /// <summary>
        /// Writes invocation exception.
        /// </summary>
        public static void WriteException(TextWriter writer, Exception ex)
        {
            if (ex == null)
            {
                return;
            }

            writer.WriteLine("ERROR:");
            writer.WriteLine(ex.GetType().Name + ":");
            writer.WriteLine(ex.Message);

            if (ex is RuntimeException asRuntimeException && asRuntimeException.ErrorRecord != null && asRuntimeException.ErrorRecord.InvocationInfo != null)
            {
                writer.WriteLine(Kit.PositionMessage(asRuntimeException.ErrorRecord.InvocationInfo.PositionMessage));
            }
        }
Exemple #2
0
        /// <summary>
        /// Writes invocation errors.
        /// </summary>
        public static void WriteErrors(TextWriter writer, IEnumerable errors)
        {
            if (errors == null)
            {
                return;
            }

            foreach (object error in errors)
            {
                writer.WriteLine("ERROR:");
                writer.WriteLine(error.ToString());

                ErrorRecord asErrorRecord = Cast <ErrorRecord> .From(error);

                if (asErrorRecord != null && asErrorRecord.InvocationInfo != null)
                {
                    writer.WriteLine(Kit.PositionMessage(asErrorRecord.InvocationInfo.PositionMessage));
                }
            }
        }