System.Management.Automation.SessionStateUnauthorizedAccessException.CreateError C# (CSharp) Method

CreateError() static private method

static private CreateError ( PSVariable variable, string message, string errorId ) : SessionStateUnauthorizedAccessException
variable PSVariable
message string
errorId string
return SessionStateUnauthorizedAccessException
        static SessionStateUnauthorizedAccessException CreateError(
            PSVariable variable,
            string message,
            string errorId)
        {
            var ex = new SessionStateUnauthorizedAccessException(
                message,
                variable.Name,
                SessionStateCategory.Variable);

            var error = new ErrorRecord(
                new ParentContainsErrorRecordException(ex),
                errorId,
                ErrorCategory.WriteError,
                variable.Name);

            ex.ErrorRecord = error;
            ex.Source = typeof(PSVariable).Namespace;

            return ex;
        }