Improve Error handling across the board
This commit is contained in:
@@ -26,6 +26,8 @@ Namespace Documents
|
||||
''' </summary>
|
||||
Public Property Selected As Boolean = False
|
||||
|
||||
Private DocumentErrors As New List(Of DocumentError)
|
||||
|
||||
Public ReadOnly Property HasErrors As Boolean
|
||||
Get
|
||||
Return Errors.Count > 0
|
||||
@@ -34,8 +36,11 @@ Namespace Documents
|
||||
|
||||
Public ReadOnly Property Errors As List(Of String)
|
||||
Get
|
||||
Dim oRowErrors = Rows.SelectMany(Function(row) row.Errors).ToList()
|
||||
Dim oDocumentErrors As List(Of String) = GetDocumentErrors().
|
||||
Dim oRowErrors = Rows.
|
||||
SelectMany(Function(row) row.Errors, Function(row, err) err.ToString).
|
||||
ToList()
|
||||
|
||||
Dim oDocumentErrors As List(Of String) = DocumentErrors.
|
||||
Select(Function(err) err.ToString()).
|
||||
ToList()
|
||||
Return oDocumentErrors.
|
||||
@@ -44,6 +49,13 @@ Namespace Documents
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub AddDocumentError(pDocumentError As DocumentErrorType, pMessage As String)
|
||||
DocumentErrors.Add(New DocumentError With {
|
||||
.Type = pDocumentError,
|
||||
.Message = pMessage
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property MandatorId As String
|
||||
Get
|
||||
Return Mandator?.Id
|
||||
@@ -84,19 +96,12 @@ Namespace Documents
|
||||
End Function
|
||||
|
||||
Public Overrides Function Equals(obj As Object) As Boolean
|
||||
Return FullName = DirectCast(obj, Document).FullName
|
||||
End Function
|
||||
|
||||
Private Function GetDocumentErrors() As List(Of DocumentError)
|
||||
Dim oErrors As New List(Of DocumentError)
|
||||
|
||||
If Mandator Is Nothing Then
|
||||
oErrors.Add(DocumentError.MandatorNotFound)
|
||||
If obj Is Nothing Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return oErrors
|
||||
Return FullName = DirectCast(obj, Document).FullName
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user