Improve Error handling across the board

This commit is contained in:
Jonathan Jenne
2022-04-26 12:02:00 +02:00
parent 13af72dee5
commit 3e41502766
19 changed files with 404 additions and 141 deletions

View File

@@ -35,11 +35,11 @@ Namespace Documents
End Get
End Property
Public ReadOnly Property Errors As List(Of String)
Public ReadOnly Property Errors As List(Of FieldError)
Get
Return Fields.
Where(Function(f) f.Value.HasError).
Select(Function(f) $"{f.Key} has Error: {f.Value.Error}").ToList()
SelectMany(Function(f) f.Value.Errors).ToList()
End Get
End Property
@@ -57,11 +57,8 @@ Namespace Documents
Private _Original As String = ""
Public Property DataType As ColumnType = ColumnType.String
Public Property [Error] As FieldError = FieldError.None
Public Sub New()
End Sub
Public Property Errors As New List(Of FieldError)
Public Property Original As String
Get
@@ -107,9 +104,17 @@ Namespace Documents
End Select
End Function
Public Sub AddFieldError(pType As FieldErrorType, pMessage As String)
Errors.Add(New FieldError() With {
.Type = pType,
.Message = pMessage
})
End Sub
Public ReadOnly Property HasError As Boolean
Get
Return [Error] <> FieldError.None Or (IsRequired And Final = String.Empty)
' Required check was moved to DocumentLoader
Return Errors.Count > 0 'Or (IsRequired And Final = String.Empty)
End Get
End Property