better handling of invalid zugferd files

This commit is contained in:
Jonathan Jenne
2019-07-04 16:09:14 +02:00
parent 90cd63c484
commit eacf8e2743
3 changed files with 46 additions and 9 deletions

View File

@@ -14,7 +14,8 @@ Public Class ZUGFeRDInterface
Public Enum ErrorType
NoValidFile
ExtractionFailed
NoZugferd
NoValidZugferd
End Enum
Public Sub New(LogConfig As LogConfig)
@@ -33,7 +34,7 @@ Public Class ZUGFeRDInterface
Dim oXmlDocument = ValidateZUGFeRDFile(Path)
If IsNothing(oXmlDocument) Then
Throw New ZUGFeRDExecption(ErrorType.ExtractionFailed, "Datei ist kein gültiges ZUGFeRD Format.")
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei.")
End If
Return SerializeZUGFeRDDocument(oXmlDocument)
@@ -70,7 +71,7 @@ Public Class ZUGFeRDInterface
If Not oProcessOutput.ToLower.Contains(ZUGFERD_CONVERTER_SUCCESS_MESSAGE.ToLower) Then
_logger.Warn("File {0} is not a valid ZUGFeRD File!", Path)
Throw New ZUGFeRDExecption(ErrorType.NoValidFile, "Datei ist kein gültiges ZUGFeRD Format.")
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei.")
End If
Try
@@ -93,7 +94,7 @@ Public Class ZUGFeRDInterface
Return oSerializer.Deserialize(oReader)
Catch ex As Exception
_logger.Error(ex)
Throw ex
Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige ZUGFeRD Datei.")
End Try
End Function
End Class