@@ -23,38 +23,70 @@ Public Class UPS_Values
2323 Public UPS_Status As Integer = Nothing
2424End Class
2525
26- Public Class UPS_Datas
27- Public Name As String = ""
28- Public Mfr As String = ""
29- Public Model As String = ""
30- Public Serial As String = ""
31- Public Firmware As String = ""
26+ Public Class UPSData
27+ Public ReadOnly Mfr As String
28+ Public ReadOnly Model As String
29+ Public ReadOnly Serial As String
30+ Public ReadOnly Firmware As String
3231 Public UPS_Value As New UPS_Values
33- End Class
3432
35- Public Class Nut_Exception
36- Inherits System.ApplicationException
33+ Public Sub New (Mfr As String , Model As String , Serial As String , Firmware As String )
34+ Me .Mfr = Mfr
35+ Me .Model = Model
36+ Me .Serial = Serial
37+ Me .Firmware = Firmware
38+ End Sub
3739
38- Public Property ExceptionValue As Nut_Exception_Value
39- Public Property ProtocolError As NUTResponse
40+ End Class
4041
41- Public Sub New ( ByVal Nut_Error_Lvl As Nut_Exception_Value)
42- MyBase .New(StringEnum.GetStringValue(Nut_Error_Lvl))
43- End Sub
42+ ''' <summary>
43+ ''' Encapsulates a query and response between a NUT client and server.
44+ ''' </summary>
45+ Public Class Transaction
46+ ''' <summary>
47+ ''' The original query sent by the client, to the server.
48+ ''' </summary>
49+ ''' <returns></returns>
50+ Public ReadOnly Property Query As String
51+ ''' <summary>
52+ ''' See <see cref="NUTResponse"/>
53+ ''' </summary>
54+ ''' <returns></returns>
55+ Public ReadOnly Property ResponseType As NUTResponse
56+ ''' <summary>
57+ ''' The full, unaltered response from the server.
58+ ''' </summary>
59+ ''' <returns></returns>
60+ Public ReadOnly Property RawResponse As String
4461
45- Public Sub New ( ByVal Nut_Error_Lvl As Nut_Exception_Value, ByVal Message As String , Optional innerEx As Exception = Nothing )
46- MyBase .New(StringEnum.GetStringValue(Nut_Error_Lvl) & Message, innerEx)
47- ExceptionValue = Nut_Error_Lvl
62+ Public Sub New (query As String , rawResponse As String , responseType As NUTResponse)
63+ Me .Query = query
64+ Me .RawResponse = rawResponse
65+ Me .ResponseType = responseType
4866 End Sub
67+ End Class
68+
69+ Public Class NutException
70+ Inherits ApplicationException
71+
72+ Public ReadOnly Property LastTransaction As Transaction
4973
5074 ''' <summary>
51- ''' Raise a Nut_Exception that resulted from an error as part of the NUT protocol.
75+ ''' Raise a NutException that resulted from either an error as part of the NUT protocol, or a general error during
76+ ''' the query.
5277 ''' </summary>
5378 ''' <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
79+ ''' <param name="queryResponse"></param>
80+ Public Sub New (query As String , protocolError As NUTResponse, queryResponse As String ,
81+ Optional innerException As Exception = Nothing )
82+ MyBase .New( Nothing , innerException)
83+ LastTransaction = New Transaction(query, queryResponse, protocolError)
84+ End Sub
85+
86+ Public Sub New (transaction As Transaction)
87+ MyBase .New( String .Format( "{0} ({1})" & vbNewLine & "Query: {2}" , transaction.ResponseType,
88+ transaction.RawResponse, transaction.Query))
89+ LastTransaction = transaction
5890 End Sub
5991End Class
6092
0 commit comments