Inheritance: ArgumentNullException, IContainsErrorRecord
Esempio n. 1
0
        internal PSArgumentNullException NewArgumentNullException(
            string paramName)
        {
            string message = !string.IsNullOrEmpty(paramName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ArgumentNull", (object)paramName) : throw new ArgumentNullException(nameof(paramName));
            PSArgumentNullException argumentNullException = new PSArgumentNullException(paramName, message);

            this.TraceException((Exception)argumentNullException);
            return(argumentNullException);
        }
Esempio n. 2
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This is not allowed to call other
        /// Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was null
        /// </param>
        /// <returns>Exception instance ready to throw.</returns>
        internal static PSArgumentNullException NewArgumentNullException(string paramName)
        {
            if (string.IsNullOrEmpty(paramName))
            {
                throw new ArgumentNullException(nameof(paramName));
            }

            string message = StringUtil.Format(AutomationExceptions.ArgumentNull, paramName);
            var    e       = new PSArgumentNullException(paramName, message);

            return(e);
        }
Esempio n. 3
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant allows the caller to
        /// specify alternate template text, but only in assembly S.M.A.Core.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was invalid
        /// </param>
        /// <param name="resourceString">
        /// The template string for this error
        /// </param>
        /// <param name="args">
        /// Objects corresponding to {0}, {1}, etc. in the resource string
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentNullException NewArgumentNullException(
            string paramName, string resourceString, params object[] args)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw NewArgumentNullException("paramName");
            }
            if (String.IsNullOrEmpty(resourceString))
            {
                throw NewArgumentNullException("resourceString");
            }

            string message = StringUtil.Format(resourceString, args);

            // Note that the paramName param comes first
            var e = new PSArgumentNullException(paramName, message);

            return(e);
        }
Esempio n. 4
0
        internal PSArgumentNullException NewArgumentNullException(
            string paramName,
            string baseName,
            string resourceId,
            params object[] args)
        {
            if (string.IsNullOrEmpty(paramName))
            {
                throw this.NewArgumentNullException(nameof(paramName));
            }
            if (string.IsNullOrEmpty(baseName))
            {
                throw this.NewArgumentNullException(nameof(baseName));
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw this.NewArgumentNullException(nameof(resourceId));
            }
            string message = ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args);
            PSArgumentNullException argumentNullException = new PSArgumentNullException(paramName, message);

            this.TraceException((Exception)argumentNullException);
            return(argumentNullException);
        }
Esempio n. 5
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant allows the caller to
        /// specify alternate template text, but only in assembly S.M.A.Core.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was invalid
        /// </param>
        /// <param name="resourceString">
        /// The template string for this error
        /// </param>
        /// <param name="args">
        /// Objects corresponding to {0}, {1}, etc. in the resource string
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentNullException NewArgumentNullException(
            string paramName, string resourceString, params object[] args)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw NewArgumentNullException("paramName");
            }
            if (String.IsNullOrEmpty(resourceString))
            {
                throw NewArgumentNullException("resourceString");
            }

            string message = StringUtil.Format(resourceString, args);

            // Note that the paramName param comes first
            var e = new PSArgumentNullException(paramName, message);

            return e;
        }
Esempio n. 6
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This is not allowed to call other
        /// Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was null
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentNullException NewArgumentNullException(string paramName)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw new ArgumentNullException("paramName");
            }

            string message = StringUtil.Format(AutomationExceptions.ArgumentNull, paramName);
            var e = new PSArgumentNullException(paramName, message);

            return e;
        }