Skip to content

Commit f608d51

Browse files
committed
Large changes to Socket/UPS handling
- New Nut_Exception constructor to allow specifying NUTResponse instead of _Exception_Value - Shifted some responsibility of error handling out of Socket class and into UPS class. These are some major changes and need testing. - Merged Create_Socket code into Connect code - Renamed and then commented-out IsKnownUPS function. Feels like this should be a part of the UPS class, but regardless, we'll know if there's an invalid UPS the moment a command is run for one. - Simplified & renamed Query_Desc function - Added a few events to the UPS class for informing any listeners of issues - UPS no longer handles socket errors, and instead passively notifies listeners about one - GetUPSVar supports DATA-STALE errors and will retry 3 times to get the data, and then take the default value and raise an event about the error. - If error is encountered when opening the ListVarGUI, display a message box and close the form. - Removed the Unknown_UPS event and modified the GUI to handle future errors.
1 parent 23ea925 commit f608d51

File tree

5 files changed

+360
-286
lines changed

5 files changed

+360
-286
lines changed

WinNUT_V2/WinNUT-Client_Common/Common_Classes.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Public Class Nut_Exception
3636
Inherits System.ApplicationException
3737

3838
Public Property ExceptionValue As Nut_Exception_Value
39+
Public Property ProtocolError As NUTResponse
3940

4041
Public Sub New(ByVal Nut_Error_Lvl As Nut_Exception_Value)
4142
MyBase.New(StringEnum.GetStringValue(Nut_Error_Lvl))
@@ -45,6 +46,16 @@ Public Class Nut_Exception
4546
MyBase.New(StringEnum.GetStringValue(Nut_Error_Lvl) & Message, innerEx)
4647
ExceptionValue = Nut_Error_Lvl
4748
End Sub
49+
50+
''' <summary>
51+
''' Raise a Nut_Exception that resulted from an error as part of the NUT protocol.
52+
''' </summary>
53+
''' <param name="protocolError"></param>
54+
''' <param name="message"></param>
55+
Public Sub New(protocolError As NUTResponse, message As String)
56+
MyBase.New(message)
57+
Me.ProtocolError = protocolError
58+
End Sub
4859
End Class
4960

5061
Public Class Nut_Parameter

0 commit comments

Comments
 (0)