Exemplo n.º 1
0
        internal static void SetCmdletErrorType(Guid cmdletUniqueId, string errorType)
        {
            string a = CmdletStaticDataWithUniqueId <string> .Get(cmdletUniqueId);

            if (a == "UnHandled")
            {
                return;
            }
            CmdletStaticDataWithUniqueId <string> .Set(cmdletUniqueId, errorType);

            CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ErrorType, errorType);
        }
        // Token: 0x06001606 RID: 5638 RVA: 0x000522DC File Offset: 0x000504DC
        private void OnError(object sender, GenericEventArg <TaskErrorEventArg> genericEventArg)
        {
            if (genericEventArg.Data.ExceptionHandled)
            {
                return;
            }
            Exception exception = genericEventArg.Data.Exception;
            Guid      uniqueId  = this.context.UniqueId;
            Exception ex        = CmdletStaticDataWithUniqueId <Exception> .Get(uniqueId);

            if (ex != null && ex != exception)
            {
                CmdletLogger.SafeAppendGenericError(uniqueId, this.context.Stage.ToString() + ".FromWriteError", ex.ToString(), false);
            }
            bool isUnhandledException = (genericEventArg.Data.IsUnknownException != null) ? genericEventArg.Data.IsUnknownException.Value : TaskHelper.IsTaskUnhandledException(exception);

            CmdletLogger.SafeAppendGenericError(uniqueId, this.context.Stage.ToString(), exception.ToString(), isUnhandledException);
            if (exception is LocalizedException)
            {
                CmdletLogger.SafeAppendGenericError(uniqueId, "ExceptionStringId", ((LocalizedException)exception).LocalizedString.StringId, false);
                if (CmdletLogHelper.NeedConvertLogMessageToUS)
                {
                    LocalizedException ex2            = (LocalizedException)exception;
                    IFormatProvider    formatProvider = ex2.FormatProvider;
                    try
                    {
                        ex2.FormatProvider = CmdletLogHelper.DefaultLoggingCulture;
                        CmdletLogger.SafeAppendGenericError(uniqueId, this.context.Stage.ToString() + "(en-us)", ex2.ToString(), false);
                    }
                    finally
                    {
                        ex2.FormatProvider = formatProvider;
                    }
                }
            }
        }