Esempio n. 1
0
        public virtual ErrorFormatEntryData GenerateErrorFormatEntry(PSObject errorData)
        {
            ErrorRecord errorRecord;

            if (errorData.BaseObject is ErrorRecord)
            {
                errorRecord = (ErrorRecord)errorData.BaseObject;
            }
            else if (errorData.BaseObject is IContainsErrorRecord)
            {
                errorRecord = ((IContainsErrorRecord)errorData.BaseObject).ErrorRecord;
            }
            else if (errorData.BaseObject is Exception)
            {
                errorRecord = new ErrorRecord((Exception)errorData.BaseObject, "Exception",
                                              ErrorCategory.NotSpecified, null);
            }
            else
            {
                var msg = "Cannot generate ErrorFormatEntry from non-error. This is a bug, please report this issue!";
                throw new NotImplementedException(msg);
            }
            var message = errorRecord.Exception == null ? "Unknown Error" : errorRecord.Exception.Message;
            var entry   = new ErrorFormatEntryData(Shape, message, errorRecord.CategoryInfo.ToString(),
                                                   errorRecord.FullyQualifiedErrorId);

            entry.WriteToErrorStream = errorData.WriteToErrorStream;
            return(entry);
        }
Esempio n. 2
0
 protected virtual void ProcessFormatEntry(ErrorFormatEntryData data)
 {
     OutputWriter.WriteToErrorStream = data.WriteToErrorStream;
     OutputWriter.WriteLine(data.Message);
     OutputWriter.WriteLine("  +CategoryInfo: " + data.CategoryInfo);
     OutputWriter.WriteLine("  +FullyQualifiedErrorId: " + data.FullyQualifiedErrorId);
 }
Esempio n. 3
0
 public virtual ErrorFormatEntryData GenerateErrorFormatEntry(PSObject errorData)
 {
     ErrorRecord errorRecord;
     if (errorData.BaseObject is ErrorRecord)
     {
         errorRecord = (ErrorRecord)errorData.BaseObject;
     }
     else if (errorData.BaseObject is IContainsErrorRecord)
     {
         errorRecord = ((IContainsErrorRecord)errorData).ErrorRecord;
     }
     else if (errorData.BaseObject is Exception)
     {
         errorRecord = new ErrorRecord((Exception)errorData.BaseObject, "Exception",
                                       ErrorCategory.NotSpecified, null);
     }
     else
     {
         var msg = "Cannot generate ErrorFormatEntry from non-error. This is a bug, please report this issue!";
         throw new NotImplementedException(msg);
     }
     var message = errorRecord.Exception == null ? "Unknown Error" : errorRecord.Exception.Message;
     var entry = new ErrorFormatEntryData(Shape, message, errorRecord.CategoryInfo.ToString(),
                                     errorRecord.FullyQualifiedErrorId);
     entry.WriteToErrorStream = errorData.WriteToErrorStream;
     return entry;
 }
Esempio n. 4
0
 protected virtual void ProcessFormatEntry(ErrorFormatEntryData data)
 {
     OutputWriter.WriteToErrorStream = data.WriteToErrorStream;
     OutputWriter.WriteLine(data.Message);
     OutputWriter.WriteLine("  +CategoryInfo: " + data.CategoryInfo);
     OutputWriter.WriteLine("  +FullyQualifiedErrorId: " + data.FullyQualifiedErrorId);
 }