Jelajahi Sumber

Added a fail exception for posting with a message intended for the user.

Kenric Nugteren 1 tahun lalu
induk
melakukan
1189b341ab

+ 5 - 0
InABox.Core/Postable/PostExceptions.cs

@@ -11,6 +11,11 @@ namespace InABox.Core
             public EmptyPostException() { }
         }
 
+        public class PostFailedMessageException : Exception
+        {
+            public PostFailedMessageException(string message): base(message) { }
+        }
+
         public class MissingSettingsException : Exception
         {
             public Type PostableType { get; }

+ 4 - 0
InABox.Core/Postable/PosterEngine.cs

@@ -163,6 +163,10 @@ namespace InABox.Core
                 SetFailed(entities);
                 throw;
             }
+            catch (PostFailedMessageException)
+            {
+                throw;
+            }
             catch(Exception e)
             {
                 Logger.Send(LogType.Error, "", $"Post Failed: {CoreUtils.FormatException(e)}");

+ 31 - 32
inabox.wpf/DynamicGrid/DynamicEditorPage.cs

@@ -4,39 +4,39 @@ using System.Collections.Generic;
 using System.Windows;
 using InABox.Core;
 
-namespace InABox.DynamicGrid
+namespace InABox.DynamicGrid;
+
+public enum PageType
 {
-    public enum PageType
-    {
-        Editor,
-        Other
-    }
+    Editor,
+    Other
+}
 
-    public interface IDynamicEditorPage
-    {
-        DynamicEditorGrid EditorGrid { get; set; }
+public interface IDynamicEditorPage
+{
+    DynamicEditorGrid EditorGrid { get; set; }
 
-        PageType PageType { get; }
+    PageType PageType { get; }
 
-        bool Ready { get; set; }
+    bool Ready { get; set; }
 
-        bool ReadOnly { get; set; }
+    bool ReadOnly { get; set; }
 
-        void Load(object item, Func<Type, CoreTable?>? PageDataHandler);
+    void Load(object item, Func<Type, CoreTable?>? PageDataHandler);
 
-        void BeforeSave(object item);
+    void BeforeSave(object item);
 
-        void AfterSave(object item);
+    void AfterSave(object item);
 
-        event EventHandler OnChanged;
-        void DoChanged();
+    event EventHandler OnChanged;
+    void DoChanged();
 
-        Size MinimumSize();
+    Size MinimumSize();
 
-        string Caption();
+    string Caption();
 
-        int Order();
-    }
+    int Order();
+}
 
 //public class DynamicEditorPage 
 //{
@@ -51,17 +51,16 @@ namespace InABox.DynamicGrid
 
 //}
 
-    public class DynamicEditorPages : List<IDynamicEditorPage>
+public class DynamicEditorPages : List<IDynamicEditorPage>
+{
+    public DynamicEditorPages() : base()
+    {
+        
+    }
+
+    public DynamicEditorPages(IEnumerable<IDynamicEditorPage> pages) : this()
     {
-        public DynamicEditorPages() : base()
-        {
-            
-        }
-
-        public DynamicEditorPages(IEnumerable<IDynamicEditorPage> pages) : this()
-        {
-            foreach (var page in pages)
-                Add(page);
-        }
+        foreach (var page in pages)
+            Add(page);
     }
 }