protected virtual void WriteError(Exception exception, ErrorIds errorIds, ErrorCategory errorCategory, object targetObject, bool throwTerminatingError = false) { var record = new ErrorRecord(exception, errorIds.ToString(), errorCategory, targetObject); PowerShellLog.Error($"'{errorIds}' (Category: {errorCategory}) error encountered on object. ", exception); if (throwTerminatingError) { ThrowTerminatingError(record); } WriteError(record); }
public virtual void WriteError(Type exceptionType, string error, ErrorIds errorIds, ErrorCategory errorCategory, object targetObject, bool throwTerminatingError = false) { var exceptionInstance = (Exception)Activator.CreateInstance(exceptionType, error); var record = new ErrorRecord(exceptionInstance, errorIds.ToString(), errorCategory, targetObject); if (throwTerminatingError) { ThrowTerminatingError(record); } WriteError(record); }