Refactored the error message
This commit is contained in:
@@ -375,11 +375,11 @@ namespace Meade.net.UnitTests
|
|||||||
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = ""; });
|
_serialMock.Setup(x => x.Transmit("#:GG#")).Callback(() => { serialPortReturn = ""; });
|
||||||
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
_serialMock.Setup(x => x.ReceiveTerminated("#")).Returns(() => serialPortReturn);
|
||||||
|
|
||||||
var result = Assert.Throws<FormatException>(() =>
|
var result = Assert.Throws<Exception>(() =>
|
||||||
{
|
{
|
||||||
SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
|
SharedResources.Connect(deviceId, string.Empty, _traceLoggerMock.Object);
|
||||||
});
|
});
|
||||||
Assert.That(result.Message, Is.EqualTo("Input string was not in a correct format."));
|
Assert.That(result.Message, Is.EqualTo("Unable to decode response from the telescope, This is likely a hardware serial communications error."));
|
||||||
|
|
||||||
_traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once);
|
_traceLoggerMock.Verify( x => x.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error."), Times.Once);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ASCOM.Meade.net.Wrapper;
|
using ASCOM.Meade.net.Wrapper;
|
||||||
@@ -309,16 +310,13 @@ namespace ASCOM.Meade.net
|
|||||||
//Returns: sHH# or sHH.H#
|
//Returns: sHH# or sHH.H#
|
||||||
//The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the
|
//The number of decimal hours to add to local time to convert it to UTC. If the number is a whole number the
|
||||||
//sHH# form is returned, otherwise the longer form is returned.
|
//sHH# form is returned, otherwise the longer form is returned.
|
||||||
try
|
double utcOffsetHours;
|
||||||
{
|
if (!double.TryParse(utcOffSet, out utcOffsetHours))
|
||||||
double.Parse(utcOffSet);
|
{
|
||||||
}
|
var message = "Unable to decode response from the telescope, This is likely a hardware serial communications error.";
|
||||||
catch (Exception)
|
traceLogger.LogIssue("Connect", message);
|
||||||
{
|
throw new Exception(message);
|
||||||
traceLogger.LogIssue("Connect", "Unable to decode response from the telescope, This is likely a hardware serial communications error.");
|
}
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user