diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 47d4ba3..df3637c 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -220,7 +220,7 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - string parameters = $"Count"; + string parameters = "Count"; var result = _telescope.Action("site", parameters); Assert.That(result, Is.EqualTo("4")); diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 67ad2b8..96173de 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -5,6 +5,8 @@ using System.Collections; using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; using ASCOM.Astrometry; using ASCOM.Astrometry.AstroUtils; using ASCOM.Astrometry.NOVAS; @@ -79,15 +81,45 @@ namespace ASCOM.Meade.net /// public Telescope() { - //todo move this out to IOC - var util = new Util(); //Initialise util object - _utilities = util; - _utilitiesExtra = util; //Initialise util object - _astroUtilities = new AstroUtils(); // Initialise astro utilities object - _sharedResourcesWrapper = new SharedResourcesWrapper(); - _astroMaths = new AstroMaths.AstroMaths(); + try + { + //todo move this out to IOC + var util = new Util(); //Initialise util object + _utilities = util; + _utilitiesExtra = util; //Initialise util object + _astroUtilities = new AstroUtils(); // Initialise astro utilities object + _sharedResourcesWrapper = new SharedResourcesWrapper(); + _astroMaths = new AstroMaths.AstroMaths(); - Initialise(); + Initialise(); + } + catch (Exception e) + { + StringBuilder sb = new StringBuilder(); + + var currentException = e; + + while (currentException != null) + { + AppendException(sb, currentException); + + currentException = currentException.InnerException; + + if (currentException != null) + sb.AppendLine("-----"); + } + + MessageBox.Show(sb.ToString()); + throw; + } + } + + private void AppendException(StringBuilder sb, Exception currentException) + { + sb.AppendLine(currentException.Message); + sb.AppendLine(); + sb.AppendLine(currentException.StackTrace); + sb.AppendLine(); } public Telescope( IUtil util, IUtilExtra utilExtra, IAstroUtils astroUtilities, ISharedResourcesWrapper sharedResourcesWrapper, IAstroMaths astroMaths)