Ejemplo n.º 1
0
        public void CreateFromInstallerExceptionForRecord()
        {
            // Construct an InstallerException from Windows Installer record data.
            var iex  = new InstallerException();
            var data = new object[] { 1715, "TEST" };

            iex.GetType().GetField("errorData", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(iex, data);

            using (var psiex = new PSInstallerException(iex))
            {
                var error = psiex.ErrorRecord;

                Assert.IsNotNull(error);
                Assert.AreEqual("Installed TEST", psiex.Message, true);
                Assert.AreEqual("TEST", error.TargetObject as string, true);
            }
        }
Ejemplo n.º 2
0
        public static DialogViewModel CreateDialog(this InstallerException ex)
        {
            var exitCode = $"ExitCode:{ex.ExitCode}";

            switch (ex.ExitReason?.Category)
            {
            case ExitCodeTypes.CorruptInstaller:
            {
                var headerVm = new DialogHeaderViewModel($"Installer for {ex.PackageManifest.Name} is corrupted.",
                                                         exitCode,
                                                         "exclamation-triangle ",
                                                         Accents.Warn);
                return(new DialogViewModel(headerVm));
            }

            case ExitCodeTypes.RequirementUnmet:
            {
                var headerVm = new DialogHeaderViewModel(@"Installer has reported that your system doesn't meet one of it's requirements.",
                                                         exitCode,
                                                         "exclamation-triangle",
                                                         Accents.Warn);
                return(new DialogViewModel(headerVm));
            }

            case ExitCodeTypes.RestartRequired:
            {
                var headerVm = new DialogHeaderViewModel($"{ex.PackageManifest.Name} has requested a system restart to finish installation.",
                                                         "",
                                                         "undo",
                                                         Accents.Warn);
                return(new DialogViewModel(headerVm));
            }

            case ExitCodeTypes.UserCanceled:
            {
                var headerVm = new DialogHeaderViewModel("User has canceled the installation",
                                                         "But you probably knew that :)",
                                                         "user-times",
                                                         Accents.Info);
                return(new DialogViewModel(headerVm));
            }
            }

            return(new DialogViewModel(new DialogHeaderViewModel($"Installer for {ex.PackageManifest.Name} exited with a non-success status code",
                                                                 exitCode, "exclamation-triangle", Accents.Error)));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a <see cref="PSInstallerException"/> from the given inner exception.
 /// </summary>
 /// <param name="innerException">The <see cref="InstallerException"/> containing error details.</param>
 public PSInstallerException(InstallerException innerException) : base(null, innerException)
 {
     this.errorRecord = null;
     this.record      = null;
 }