From 8231c057a4073e7397dbb1d953c43a76d8187e72 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 12 Feb 2018 12:53:46 +0200 Subject: Implemented global exception trapping on machine studio. --- .../Windows/ExceptionResolutions.cs | 15 ++++++ .../Windows/ExceptionWindow.xaml | 61 ++++++++++++++++++++++ .../Windows/ExceptionWindow.xaml.cs | 48 +++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs new file mode 100644 index 000000000..2e7327559 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionResolutions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.UI.Windows +{ + public enum ExceptionResolutions + { + Shutdown, + Restart, + Ignore + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml new file mode 100644 index 000000000..c08a08842 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Machine Studio encountered an unexpected error. It is recommended to restart the application in order to resolve the issue. + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs new file mode 100644 index 000000000..0f74fee17 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using Tango.Core.Commands; +using Tango.MachineStudio.UI.ViewModels; + +namespace Tango.MachineStudio.UI.Windows +{ + /// + /// Interaction logic for ExceptionWindow.xaml + /// + public partial class ExceptionWindow : Window + { + public ExceptionResolutions Resolution { get; set; } + + public String Exception { get; set; } + + public RelayCommand ResolveCommand { get; set; } + + public ExceptionWindow() + { + InitializeComponent(); + DataContext = this; + } + + public ExceptionWindow(Exception ex) : this() + { + Exception = ex.FlattenException(); + ResolveCommand = new RelayCommand(Resolve); + } + + private void Resolve(ExceptionResolutions resolution) + { + Resolution = resolution; + Close(); + } + } +} -- cgit v1.3.1