This document provides examples of how to use the ErrorCode enum in the ZuGFeRD Validator REST API.
The ErrorCode enum contains validation error codes from two sources:
- Mustang CLI errors (1-27): Standard validation errors from the Mustang validator
- Custom application errors (1000+): Application-specific errors
When validation fails, the API returns a FileValidationResponse with an error code:
{
"success": false,
"errorCode": "FileNotFound",
"errorMessage": "File not found",
"validationReport": null
}The errorCode field is serialized as a string (e.g., "FileNotFound") for better API usability.
using Docentric.EInvoice.Validator.RestServer.Contracts;
var errorCode = ErrorCode.FileNotFound;
string friendlyMessage = errorCode.GetFriendlyMessage();
// Output: "File not found"var errorCode = ErrorCode.SchematronRuleFailed;
if (errorCode.IsMustangError())
{
Console.WriteLine("This is a Mustang CLI validation error");
}
if (errorCode.IsCustomError())
{
Console.WriteLine("This is a custom application error");
}var response = new FileValidationResponse
{
Success = false,
ErrorCode = ErrorCode.XmlDataNotFound,
ErrorMessage = ErrorCode.XmlDataNotFound.GetFriendlyMessage(),
ValidationReport = null
};FileNotFound(1): The specified file could not be foundFileTooSmall(5): File is too small to be a valid ZuGFeRD/Factur-X documentInvalidFileFormat(8): File doesn't appear to be PDF or XML
NotAPdf(20): File is not a valid PDFNotAPdfA3(23): PDF is not in PDF/A-3 format (required for ZuGFeRD)VeraPdfException(6): PDF validation failed
XmlDataNotFound(3): No embedded XML found in PDFSchemaValidationFailed(18): XML doesn't conform to schemaSchematronRuleFailed(4): Business rule validation failed
ArithmeticalError(10): Calculated totals don't match document totalsEn16931SchematronCheckFailed(24): EN16931 standard validation failedXRechnungSchematronValidationFailed(27): XRechnung validation failed
XmpConformanceLevelNotFound(11): Required conformance level not foundXmpVersionNotFound(15): Required version not foundXmpDocumentTypeNotFound(13): Required document type not found
UnknownError(1000): Unspecified errorInvalidRequest(1001): Invalid request parametersProcessingTimeout(1002): Processing took too longInternalServerError(1003): Server error during processing
When sending requests to the API, error codes can be specified as:
{
"errorCode": "FileNotFound"
}Or as numeric values:
{
"errorCode": 1
}Both formats are supported thanks to JsonStringEnumConverter.
<select name="errorCode">
<option value="0">None</option>
<option value="1">FileNotFound</option>
<option value="3">XmlDataNotFound</option>
<!-- ... -->
</select>| Code | Name | Description |
|---|---|---|
| 0 | None | No error |
| 1 | FileNotFound | File not found |
| 2 | AdditionalDataSchemaValidationFailed | Additional data schema validation failed |
| 3 | XmlDataNotFound | XML data not found |
| 4 | SchematronRuleFailed | Schematron rule failed |
| 5 | FileTooSmall | File too small |
| 6 | VeraPdfException | VeraPDF exception |
| 7 | IoExceptionPdf | IOException while processing PDF |
| 8 | InvalidFileFormat | File does not appear to be PDF or XML |
| 9 | IoExceptionXml | IOException while processing XML |
| 10 | ArithmeticalError | Calculated sums/totals do not match |
| 11-27 | [Various XMP/Validation Errors] | See code documentation |
| 1000+ | [Custom Application Errors] | Application-specific errors |
For the complete list of error codes and their descriptions, refer to the ErrorCode enum in the source code.