当前位置: 首页>>代码示例>>C#>>正文


C# Cmdlet.WriteError方法代码示例

本文整理汇总了C#中Cmdlet.WriteError方法的典型用法代码示例。如果您正苦于以下问题:C# Cmdlet.WriteError方法的具体用法?C# Cmdlet.WriteError怎么用?C# Cmdlet.WriteError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cmdlet的用法示例。


在下文中一共展示了Cmdlet.WriteError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteErrorDetails

        /// <summary>
        /// Process the exception that was thrown and write the error details.
        /// </summary>
        /// <param name="cmdlet">The cmdlet for which to write the error output.</param>
        /// <param name="clientRequestId">The unique id for this request.</param>
        /// <param name="exception">The exception that was thrown.</param>
        public static void WriteErrorDetails(
            Cmdlet cmdlet,
            string clientRequestId,
            Exception exception)
        {
            string requestId;
            ErrorRecord errorRecord = RetrieveExceptionDetails(exception, out requestId);

            // Write the request Id as a warning
            if (requestId != null)
            {
                // requestId was availiable from the server response, write that as warning to the
                // console.
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionRequestId,
                    requestId));
            }
            else
            {
                // requestId was not availiable from the server response, write the client Ids that
                // was sent.
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionClientSessionId,
                    SqlDatabaseCmdletBase.clientSessionId));
                cmdlet.WriteWarning(string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ExceptionClientRequestId,
                    clientRequestId));
            }

            // Write the actual errorRecord containing the exception details
            cmdlet.WriteError(errorRecord);
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:41,代码来源:SqlDatabaseExceptionHandler.cs

示例2: WriteLoadError

		private static bool WriteLoadError(Cmdlet cmdlet, ArrayList loadError, string errorId)
		{
			bool flag;
			IEnumerator enumerator = loadError.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					DataFileLoadError current = (DataFileLoadError)enumerator.Current;
					if (current.status != DataFileLoadError.ErrorStatus.Warning)
					{
						if (current.status != DataFileLoadError.ErrorStatus.Error)
						{
							continue;
						}
						cmdlet.WriteError(new ErrorRecord(current.exception, errorId, ErrorCategory.InvalidOperation, null));
						flag = false;
						return flag;
					}
					else
					{
						cmdlet.WriteWarning(string.Concat(current.message, "\n\n"));
					}
				}
				return true;
			}
			finally
			{
				IDisposable disposable = enumerator as IDisposable;
				if (disposable != null)
				{
					disposable.Dispose();
				}
			}
			return flag;
		}
开发者ID:nickchal,项目名称:pash,代码行数:36,代码来源:PswaAuthorizationRuleCommandHelper.cs

示例3: LoadFromFile

		internal static SortedList<int, PswaAuthorizationRule> LoadFromFile(Cmdlet cmdlet, string operationName)
		{
			SortedList<int, PswaAuthorizationRule> nums;
			bool flag;
			SortedList<int, PswaAuthorizationRule> nums1;
			try
			{
				ArrayList arrayLists = new ArrayList();
				SortedList<int, PswaAuthorizationRule> nums2 = PswaAuthorizationRuleManager.Instance.LoadFromFile(arrayLists);
				if (!PswaAuthorizationRuleCommandHelper.WriteLoadError(cmdlet, arrayLists, string.Concat(operationName, "RuleError")))
				{
					flag = false;
				}
				else
				{
					flag = nums2 != null;
				}
				bool flag1 = flag;
				if (flag1)
				{
					nums1 = nums2;
				}
				else
				{
					nums1 = null;
				}
				nums = nums1;
			}
			catch (Exception exception1)
			{
				Exception exception = exception1;
				cmdlet.WriteError(new ErrorRecord(exception, string.Concat(operationName, "RuleError"), ErrorCategory.InvalidOperation, null));
				nums = null;
			}
			return nums;
		}
开发者ID:nickchal,项目名称:pash,代码行数:36,代码来源:PswaAuthorizationRuleCommandHelper.cs

示例4: WriteInvalidPathError

 /// <summary>
 ///     Helper routine to say that the path was invalid.
 /// </summary>
 /// <param name="cmdlet"></param>
 /// <param name="path"></param>
 public static void WriteInvalidPathError(Cmdlet cmdlet, string path)
 {
     cmdlet.WriteError(new ErrorRecord(new ArgumentException("Path not valid"),
         "InvalidArgument",
         ErrorCategory.InvalidArgument,
         path));
 }
开发者ID:c0ns0le,项目名称:OneNotePowerShellProvider,代码行数:12,代码来源:Utilities.cs

示例5: WriteGenomeHostError

 internal static void WriteGenomeHostError(Cmdlet self, string message)
 {
     self.WriteError(
         new ErrorRecord(new Exception(message), "Genome", ErrorCategory.WriteError, null));
 }
开发者ID:AlexeyEvlampiev,项目名称:genome-ctl,代码行数:5,代码来源:CmdletHelpers.cs

示例6: AdaptCardObject

 public PSObject AdaptCardObject(Cmdlet myCmdlet, card cardObject)
 {
     var promotedObject = new PSObject(cardObject);
     promotedObject.TypeNames.Insert(1, cardObject.GetType().FullName);
     promotedObject.TypeNames[0] = String.Format(CultureInfo.CurrentCulture, "CardObject#{0}",cardObject.className);
     // loop through the properties and promote them into the PSObject we're going to return
     foreach ( var p in cardObject.attributeList)
     {
         try
         {
             promotedObject.Members.Add(new PSNoteProperty(p.name, p.value));
         }
         catch (ExtendedTypeSystemException ets)
         {
             myCmdlet.WriteWarning(String.Format("The property '{0}' already exists, skipping.\nException: {1}", p.name, ets.Message));
         }
         catch (Exception e)
         {
             myCmdlet.WriteError(new ErrorRecord(e, "Property", ErrorCategory.NotSpecified, p.name));
         }
     }
     return promotedObject;
 }
开发者ID:simonfuhrer,项目名称:CMDBLets,代码行数:23,代码来源:EntityTypes.cs


注:本文中的Cmdlet.WriteError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。