summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-27 21:42:48 -0700
committerJacob Palecki <[email protected]>2020-09-27 21:42:48 -0700
commit7ccdb78b8c059de31e5b568b43f4547142d9aeb4 (patch)
tree992816135721cf33e41a373b161cfaee5d104d84
parentFix tab behavior (diff)
downloadrawaccel-7ccdb78b8c059de31e5b568b43f4547142d9aeb4.tar.xz
rawaccel-7ccdb78b8c059de31e5b568b43f4547142d9aeb4.zip
Handle errors from bad arg on write
-rw-r--r--grapher/Models/AccelGUI.cs3
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs29
2 files changed, 30 insertions, 2 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index c9c4ed0..15a0c0e 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -3,7 +3,6 @@ using grapher.Models.Mouse;
using grapher.Models.Options;
using grapher.Models.Serialized;
using System;
-using System.Drawing;
using System.Windows.Forms;
namespace grapher
@@ -97,7 +96,7 @@ namespace grapher
}
else
{
- WriteButton.Text = "bad args";
+ throw new Exception($"Bad arguments: \n {SettingsManager.ErrorStringFrom(errors)}");
}
}
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index 93cf42b..416823e 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -2,6 +2,7 @@
using System;
using System.Windows.Forms;
using System.Threading;
+using System.Text;
namespace grapher.Models.Serialized
{
@@ -47,6 +48,34 @@ namespace grapher.Models.Serialized
#region Methods
+ public static string ErrorStringFrom(SettingsErrors errors)
+ {
+ StringBuilder builder = new StringBuilder();
+ bool yPresent = errors.y?.Count > 0;
+
+ if (yPresent)
+ {
+ builder.AppendLine("\nx:");
+ }
+
+ foreach (var error in errors.x)
+ {
+ builder.AppendLine(error);
+ }
+
+ if (yPresent)
+ {
+ builder.AppendLine("\ny:");
+
+ foreach (var error in errors.y)
+ {
+ builder.AppendLine(error);
+ }
+ }
+
+ return builder.ToString();
+ }
+
public SettingsErrors TryUpdateActiveSettings(DriverSettings settings)
{
var errors = TryUpdateAccel(settings);