Пример #1
0
        internal static CimJobException CreateFromMethodErrorCode(string jobDescription, CimJobContext jobContext, string methodName, string errorCodeFromMethod)
        {
            string rawErrorMessage = string.Format(
                CultureInfo.InvariantCulture,
                CmdletizationResources.CimJob_ErrorCodeFromMethod,
                errorCodeFromMethod);

            string errorMessage = BuildErrorMessage(jobDescription, jobContext, rawErrorMessage);

            CimJobException cje = new CimJobException(errorMessage);

            cje.InitializeErrorRecord(jobContext, "CimJob_" + methodName + "_" + errorCodeFromMethod, ErrorCategory.InvalidResult);

            return(cje);
        }
Пример #2
0
        internal static CimJobException CreateWithFullControl(
            CimJobContext jobContext,
            string message,
            string errorId,
            ErrorCategory errorCategory,
            Exception inner = null)
        {
            Dbg.Assert(jobContext != null, "Caller should verify jobContext != null");
            Dbg.Assert(!string.IsNullOrEmpty(message), "Caller should verify message != null");
            Dbg.Assert(!string.IsNullOrEmpty(errorId), "Caller should verify errorId != null");

            CimJobException cimJobException = new CimJobException(jobContext.PrependComputerNameToMessage(message), inner);

            cimJobException.InitializeErrorRecord(jobContext, errorId, errorCategory);
            return(cimJobException);
        }
Пример #3
0
		internal static CimJobException CreateWithoutJobContext(string message, string errorId, ErrorCategory errorCategory, Exception inner = null)
		{
			CimJobException cimJobException = new CimJobException(message, inner);
			cimJobException.InitializeErrorRecord(null, errorId, errorCategory);
			return cimJobException;
		}
Пример #4
0
		internal static CimJobException CreateWithFullControl(CimJobContext jobContext, string message, string errorId, ErrorCategory errorCategory, Exception inner = null)
		{
			CimJobException cimJobException = new CimJobException(jobContext.PrependComputerNameToMessage(message), inner);
			cimJobException.InitializeErrorRecord(jobContext, errorId, errorCategory);
			return cimJobException;
		}
Пример #5
0
		internal static CimJobException CreateFromMethodErrorCode(string jobDescription, CimJobContext jobContext, string methodName, string errorCodeFromMethod)
		{
			object[] objArray = new object[1];
			objArray[0] = errorCodeFromMethod;
			string str = string.Format(CultureInfo.InvariantCulture, CmdletizationResources.CimJob_ErrorCodeFromMethod, objArray);
			string str1 = CimJobException.BuildErrorMessage(jobDescription, jobContext, str);
			CimJobException cimJobException = new CimJobException(str1);
			cimJobException.InitializeErrorRecord(jobContext, string.Concat("CimJob_", methodName, "_", errorCodeFromMethod), ErrorCategory.InvalidResult);
			return cimJobException;
		}
Пример #6
0
		internal static CimJobException CreateFromCimException(string jobDescription, CimJobContext jobContext, CimException cimException)
		{
			string str = CimJobException.BuildErrorMessage(jobDescription, jobContext, cimException.Message);
			CimJobException cimJobException = new CimJobException(str, cimException);
			cimJobException.InitializeErrorRecord(jobContext, cimException);
			return cimJobException;
		}
Пример #7
0
		internal static CimJobException CreateFromAnyException(string jobDescription, CimJobContext jobContext, Exception inner)
		{
			CimException cimException = inner as CimException;
			if (cimException == null)
			{
				string str = CimJobException.BuildErrorMessage(jobDescription, jobContext, inner.Message);
				CimJobException cimJobException = new CimJobException(str, inner);
				IContainsErrorRecord containsErrorRecord = inner as IContainsErrorRecord;
				if (containsErrorRecord == null)
				{
					cimJobException.InitializeErrorRecord(jobContext, string.Concat("CimJob_", inner.GetType().Name), ErrorCategory.NotSpecified);
				}
				else
				{
					cimJobException.InitializeErrorRecord(jobContext, string.Concat("CimJob_", containsErrorRecord.ErrorRecord.FullyQualifiedErrorId), containsErrorRecord.ErrorRecord.CategoryInfo.Category);
				}
				return cimJobException;
			}
			else
			{
				return CimJobException.CreateFromCimException(jobDescription, jobContext, cimException);
			}
		}
Пример #8
0
        internal static CimJobException CreateFromCimException(
            string jobDescription,
            CimJobContext jobContext,
            CimException cimException)
        {
            Dbg.Assert(!string.IsNullOrEmpty(jobDescription), "Caller should verify jobDescription != null");
            Dbg.Assert(jobContext != null, "Caller should verify jobContext != null");
            Dbg.Assert(cimException != null, "Caller should verify cimException != null");

            string message = BuildErrorMessage(jobDescription, jobContext, cimException.Message);
            CimJobException cimJobException = new CimJobException(message, cimException);
            cimJobException.InitializeErrorRecord(jobContext, cimException);
            return cimJobException;
        }
Пример #9
0
        internal static CimJobException CreateFromMethodErrorCode(string jobDescription, CimJobContext jobContext, string methodName, string errorCodeFromMethod)
        {
            string rawErrorMessage = string.Format(
                CultureInfo.InvariantCulture,
                CmdletizationResources.CimJob_ErrorCodeFromMethod,
                errorCodeFromMethod);

            string errorMessage = BuildErrorMessage(jobDescription, jobContext, rawErrorMessage);

            CimJobException cje = new CimJobException(errorMessage);
            cje.InitializeErrorRecord(jobContext, "CimJob_" + methodName + "_" + errorCodeFromMethod, ErrorCategory.InvalidResult);

            return cje;
        }
Пример #10
0
        internal static CimJobException CreateWithoutJobContext(
            string message,
            string errorId,
            ErrorCategory errorCategory,
            Exception inner = null)
        {
            Dbg.Assert(!string.IsNullOrEmpty(message), "Caller should verify message != null");
            Dbg.Assert(!string.IsNullOrEmpty(errorId), "Caller should verify errorId != null");

            CimJobException cimJobException = new CimJobException(message, inner);
            cimJobException.InitializeErrorRecord(null, errorId, errorCategory);
            return cimJobException;
        }
Пример #11
0
        internal static CimJobException CreateWithFullControl(
            CimJobContext jobContext,
            string message,
            string errorId,
            ErrorCategory errorCategory,
            Exception inner = null)
        {
            Dbg.Assert(jobContext != null, "Caller should verify jobContext != null");
            Dbg.Assert(!string.IsNullOrEmpty(message), "Caller should verify message != null");
            Dbg.Assert(!string.IsNullOrEmpty(errorId), "Caller should verify errorId != null");

            CimJobException cimJobException = new CimJobException(jobContext.PrependComputerNameToMessage(message), inner);
            cimJobException.InitializeErrorRecord(jobContext, errorId, errorCategory);
            return cimJobException;
        }
Пример #12
0
        internal static CimJobException CreateFromAnyException(
            string jobDescription,
            CimJobContext jobContext,
            Exception inner)
        {
            Dbg.Assert(!string.IsNullOrEmpty(jobDescription), "Caller should verify jobDescription != null");
            Dbg.Assert(jobContext != null, "Caller should verify jobContext != null");
            Dbg.Assert(inner != null, "Caller should verify inner != null");

            CimException cimException = inner as CimException;
            if (cimException != null)
            {
                return CreateFromCimException(jobDescription, jobContext, cimException);
            }

            string message = BuildErrorMessage(jobDescription, jobContext, inner.Message);
            CimJobException cimJobException = new CimJobException(message, inner);
            var containsErrorRecord = inner as IContainsErrorRecord;
            if (containsErrorRecord != null)
            {
                cimJobException.InitializeErrorRecord(
                    jobContext,
                    errorId: "CimJob_" + containsErrorRecord.ErrorRecord.FullyQualifiedErrorId,
                    errorCategory: containsErrorRecord.ErrorRecord.CategoryInfo.Category);
            }
            else
            {
                cimJobException.InitializeErrorRecord(
                    jobContext,
                    errorId: "CimJob_" + inner.GetType().Name,
                    errorCategory: ErrorCategory.NotSpecified);
            }
            return cimJobException;
        }