Example #1
0
        public void ShowError(Exception ex)
        {
            if (ex is NuGetResolverConstraintException ||
                ex is PackageAlreadyInstalledException ||
                ex is MinClientVersionException ||
                ex is FrameworkException ||
                ex is NuGetProtocolException ||
                ex is PackagingException ||
                ex is InvalidOperationException)
            {
                // for exceptions that are known to be normal error cases, just
                // display the message.
                ProjectContext.Log(MessageLevel.Info, ExceptionUtilities.DisplayMessage(ex, indent: true));

                // write to activity log
                var activityLogMessage = string.Format(CultureInfo.CurrentCulture, ex.ToString());
                ActivityLog.LogError(LogEntrySource, activityLogMessage);
            }
            else
            {
                ProjectContext.Log(MessageLevel.Error, ex.ToString());
            }

            UILogger.ReportError(ExceptionUtilities.DisplayMessage(ex, indent: false));
        }
Example #2
0
        private void ProcessSignatureIssues(PackageVerificationResult result, PackageIdentity packageIdentity)
        {
            var errorList   = result.GetErrorIssues().ToList();
            var warningList = result.GetWarningIssues().ToList();

            errorList.ForEach(p => UILogger.ReportError(p.Message));

            errorList.ForEach(p => ProjectContext.Log(MessageLevel.Error, p.FormatWithCode()));
            warningList.ForEach(p => ProjectContext.Log(MessageLevel.Warning, p.FormatWithCode()));
        }
Example #3
0
        public void ShowError(Exception ex)
        {
            var signException = ex as SignatureException;

            if (signException != null)
            {
                foreach (var result in signException.Results)
                {
                    ProcessSignatureIssues(result, signException.PackageIdentity);
                }
            }
            else
            {
                if (ex is NuGetResolverConstraintException ||
                    ex is PackageAlreadyInstalledException ||
                    ex is MinClientVersionException ||
                    ex is FrameworkException ||
                    ex is NuGetProtocolException ||
                    ex is PackagingException ||
                    ex is InvalidOperationException ||
                    ex is PackageReferenceRollbackException)
                {
                    // for exceptions that are known to be normal error cases, just
                    // display the message.
                    ProjectContext.Log(MessageLevel.Info, ExceptionUtilities.DisplayMessage(ex, indent: true));

                    // write to activity log
                    var activityLogMessage = string.Format(CultureInfo.CurrentCulture, ex.ToString());
                    ActivityLog.LogError(LogEntrySource, activityLogMessage);

                    // Log additional messages to the error list to provide context on why the rollback failed
                    var rollbackException = ex as PackageReferenceRollbackException;
                    if (rollbackException != null)
                    {
                        foreach (var message in rollbackException.LogMessages)
                        {
                            if (message.Level == LogLevel.Error)
                            {
                                UILogger.ReportError(message.Message);
                            }
                        }
                    }
                }
                else
                {
                    ProjectContext.Log(MessageLevel.Error, ex.ToString());
                }

                UILogger.ReportError(ExceptionUtilities.DisplayMessage(ex, indent: false));
            }
        }
Example #4
0
        private void ProcessSignatureIssues(SignatureException ex)
        {
            if (!string.IsNullOrEmpty(ex.Message))
            {
                UILogger.ReportError(ex.AsLogMessage().FormatWithCode());
                ProjectContext.Log(MessageLevel.Error, ex.AsLogMessage().FormatWithCode());
            }

            foreach (var result in ex.Results)
            {
                var errorList   = result.GetErrorIssues().ToList();
                var warningList = result.GetWarningIssues().ToList();

                errorList.ForEach(p => UILogger.ReportError(p.FormatWithCode()));

                errorList.ForEach(p => ProjectContext.Log(MessageLevel.Error, p.FormatWithCode()));
                warningList.ForEach(p => ProjectContext.Log(MessageLevel.Warning, p.FormatWithCode()));
            }
        }