/// <summary> /// TraceErrorRecord /// </summary> public bool TraceErrorRecord(ErrorRecord errorRecord) { if (errorRecord != null) { Exception exception = errorRecord.Exception; string innerException = "None"; if (exception.InnerException != null) { innerException = exception.InnerException.Message; } ErrorCategoryInfo cinfo = errorRecord.CategoryInfo; string message = "None"; if (errorRecord.ErrorDetails != null) { message = errorRecord.ErrorDetails.Message; } return(DebugChannel.TraceError(PowerShellTraceEvent.ErrorRecord, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, message, cinfo.Category.ToString(), cinfo.Reason, cinfo.TargetName, errorRecord.FullyQualifiedErrorId, exception.Message, exception.StackTrace, innerException)); } else { return(DebugChannel.TraceError(PowerShellTraceEvent.ErrorRecord, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, "NULL errorRecord")); } }
/// <summary> /// TraceException /// </summary> public bool TraceException(Exception exception) { if (exception != null) { string innerException = "None"; if (exception.InnerException != null) { innerException = exception.InnerException.Message; } return(DebugChannel.TraceError(PowerShellTraceEvent.Exception, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, exception.Message, exception.StackTrace, innerException)); } else { return(DebugChannel.TraceError(PowerShellTraceEvent.Exception, PowerShellTraceOperationCode.Exception, PowerShellTraceTask.None, "NULL exception")); } }