예제 #1
0
        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);
        }
예제 #2
0
        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);
        }