aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-23 15:54:20 -0700
committerRob Mensching <rob@firegiant.com>2021-03-23 16:37:06 -0700
commit42b570e34f9cfadbf6f6135cd6b55630c13538be (patch)
treeaba8f7048acc2fcd5f4f1286577e87c1e5c636c1 /src
parent26442d4177bd6e108f2cf4cc2fb2599e624ff6c4 (diff)
downloadwix-42b570e34f9cfadbf6f6135cd6b55630c13538be.tar.gz
wix-42b570e34f9cfadbf6f6135cd6b55630c13538be.tar.bz2
wix-42b570e34f9cfadbf6f6135cd6b55630c13538be.zip
Throw WixException for internal errors and Messaging for user errors
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs4
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs10
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs15
3 files changed, 15 insertions, 14 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
index 1cc9987e..4e07d598 100644
--- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
@@ -581,7 +581,7 @@ namespace WixToolset.Core.Burn
581 581
582 if (0 == symbols.Count) 582 if (0 == symbols.Count)
583 { 583 {
584 this.Messaging.Write(ErrorMessages.MissingBundleInformation(nameof(T))); 584 throw new WixException(ErrorMessages.MissingBundleInformation(nameof(T)));
585 } 585 }
586 586
587 return symbols; 587 return symbols;
@@ -593,7 +593,7 @@ namespace WixToolset.Core.Burn
593 593
594 if (1 != symbols.Count) 594 if (1 != symbols.Count)
595 { 595 {
596 this.Messaging.Write(ErrorMessages.MissingBundleInformation(nameof(T))); 596 throw new WixException(ErrorMessages.MissingBundleInformation(nameof(T)));
597 } 597 }
598 598
599 return symbols[0]; 599 return symbols[0];
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
index 7d75d74c..5e72ec5c 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
@@ -67,7 +67,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
67 } 67 }
68 else // not a supported unscheduled action. 68 else // not a supported unscheduled action.
69 { 69 {
70 throw new InvalidOperationException($"Found an action [{actionSymbol.Id.Id}] at [{actionSymbol.SourceLineNumbers}] with no Sequence, Before, or After column set."); 70 throw new WixException($"Found action '{actionSymbol.Id.Id}' at {actionSymbol.SourceLineNumbers}' with no Sequence, Before, or After column set. The compiler should have prevented this.");
71 } 71 }
72 } 72 }
73 73
@@ -580,7 +580,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
580 } 580 }
581 else if (actionSymbol.Before == null) 581 else if (actionSymbol.Before == null)
582 { 582 {
583 throw new InvalidOperationException($"Found an action [{actionSymbol.Id.Id}] at [{actionSymbol.SourceLineNumbers}] with no Sequence, Before, or After column set."); 583 throw new WixException($"Found action '{actionSymbol.Id.Id}' at {actionSymbol.SourceLineNumbers}' with no Sequence, Before, or After column set. The compiler should have prevented this.");
584 } 584 }
585 585
586 var parentActionName = (after ? actionSymbol.After : actionSymbol.Before); 586 var parentActionName = (after ? actionSymbol.After : actionSymbol.Before);
@@ -598,7 +598,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
598 } 598 }
599 else 599 else
600 { 600 {
601 throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Found an action with a non-existent {0} action: {1}.", (after ? "After" : "Before"), parentActionName)); 601 throw new WixException($"Found action {actionSymbol.Id.Id} with a non-existent {(after ? "After" : "Before")} action '{parentActionName}'. The linker should have prevented this.");
602 } 602 }
603 } 603 }
604 604
@@ -639,11 +639,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
639 } 639 }
640 else if (existingInitialActionSymbol == actionSymbol) 640 else if (existingInitialActionSymbol == actionSymbol)
641 { 641 {
642 throw new WixException(ErrorMessages.ActionCircularDependency(currentActionSymbol.SourceLineNumbers, currentActionSymbol.SequenceTable.ToString(), currentActionSymbol.Action, previousActionSymbol.Action)); 642 this.Messaging.Write(ErrorMessages.ActionCircularDependency(currentActionSymbol.SourceLineNumbers, currentActionSymbol.SequenceTable.ToString(), currentActionSymbol.Action, previousActionSymbol.Action));
643 } 643 }
644 644
645 parentActionSymbol = this.GetParentActionSymbol(currentActionSymbol, requiredActionSymbols); 645 parentActionSymbol = this.GetParentActionSymbol(currentActionSymbol, requiredActionSymbols);
646 } while (null != parentActionSymbol); 646 } while (null != parentActionSymbol && !this.Messaging.EncounteredError);
647 } 647 }
648 648
649 /// <summary> 649 /// <summary>
diff --git a/src/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs
index 7980ea61..636b86a6 100644
--- a/src/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/CustomActionFixture.cs
@@ -6,7 +6,6 @@ namespace WixToolsetTest.CoreIntegration
6 using System.Linq; 6 using System.Linq;
7 using WixBuildTools.TestSupport; 7 using WixBuildTools.TestSupport;
8 using WixToolset.Core.TestPackage; 8 using WixToolset.Core.TestPackage;
9 using WixToolset.Data;
10 using Xunit; 9 using Xunit;
11 10
12 public class CustomActionFixture 11 public class CustomActionFixture
@@ -22,7 +21,7 @@ namespace WixToolsetTest.CoreIntegration
22 var intermediateFolder = Path.Combine(baseFolder, "obj"); 21 var intermediateFolder = Path.Combine(baseFolder, "obj");
23 var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); 22 var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
24 23
25 var exception = Assert.Throws<WixException>(() => WixRunner.Execute(new[] 24 var result = WixRunner.Execute(new[]
26 { 25 {
27 "build", 26 "build",
28 Path.Combine(folder, "CustomAction", "CustomActionCycle.wxs"), 27 Path.Combine(folder, "CustomAction", "CustomActionCycle.wxs"),
@@ -31,9 +30,10 @@ namespace WixToolsetTest.CoreIntegration
31 "-bindpath", Path.Combine(folder, "SingleFile", "data"), 30 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
32 "-intermediateFolder", intermediateFolder, 31 "-intermediateFolder", intermediateFolder,
33 "-o", msiPath 32 "-o", msiPath
34 })); 33 });
35 34
36 Assert.Equal("The InstallExecuteSequence table contains an action 'Action1' that is scheduled to come before or after action 'Action3', which is also scheduled to come before or after action 'Action1'. Please remove this circular dependency by changing the Before or After attribute for one of the actions.", exception.Message); 35 Assert.Equal(176, result.ExitCode);
36 Assert.Equal("The InstallExecuteSequence table contains an action 'Action1' that is scheduled to come before or after action 'Action3', which is also scheduled to come before or after action 'Action1'. Please remove this circular dependency by changing the Before or After attribute for one of the actions.", result.Messages[0].ToString());
37 } 37 }
38 } 38 }
39 39
@@ -48,7 +48,7 @@ namespace WixToolsetTest.CoreIntegration
48 var intermediateFolder = Path.Combine(baseFolder, "obj"); 48 var intermediateFolder = Path.Combine(baseFolder, "obj");
49 var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); 49 var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
50 50
51 var exception = Assert.Throws<WixException>(() => WixRunner.Execute(new[] 51 var result = WixRunner.Execute(new[]
52 { 52 {
53 "build", 53 "build",
54 Path.Combine(folder, "CustomAction", "CustomActionCycleWithTail.wxs"), 54 Path.Combine(folder, "CustomAction", "CustomActionCycleWithTail.wxs"),
@@ -57,9 +57,10 @@ namespace WixToolsetTest.CoreIntegration
57 "-bindpath", Path.Combine(folder, "SingleFile", "data"), 57 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
58 "-intermediateFolder", intermediateFolder, 58 "-intermediateFolder", intermediateFolder,
59 "-o", msiPath 59 "-o", msiPath
60 })); 60 });
61 61
62 Assert.Equal("The InstallExecuteSequence table contains an action 'Action2' that is scheduled to come before or after action 'Action4', which is also scheduled to come before or after action 'Action2'. Please remove this circular dependency by changing the Before or After attribute for one of the actions.", exception.Message); 62 Assert.Equal(176, result.ExitCode);
63 Assert.Equal("The InstallExecuteSequence table contains an action 'Action2' that is scheduled to come before or after action 'Action4', which is also scheduled to come before or after action 'Action2'. Please remove this circular dependency by changing the Before or After attribute for one of the actions.", result.Messages[0].ToString());
63 } 64 }
64 } 65 }
65 66