Errores
Todas las excepciones del paquete se exportan desde el subpath @nodecfdi/xml-schema-validator/errors:
import {
NamespaceNotFoundInSchemasError,
SchemaLocationPartsNotEvenError,
ValidationFailError,
XmlContentIsEmptyError,
XmlContentIsInvalidError,
XmlSchemaValidatorError,
} from '@nodecfdi/xml-schema-validator/errors';
XmlSchemaValidatorError
export class XmlSchemaValidatorError extends Error {}
Clase base común para todas las excepciones lanzadas explícitamente por el paquete. Permite capturar cualquier error del validador con error instanceof XmlSchemaValidatorError.
ValidationFailError
Hereda de XmlSchemaValidatorError. Se lanza en SchemaValidator.validateWithSchemas() cuando el XML no cumple con alguno de los esquemas XSD.
- Mensaje:
`Schema validation failed: ${previous.message}` - Métodos:
getPrevious(): Error: devuelve el error subyacente proveniente delibxml2-wasm.static create(previous: Error): ValidationFailError
NamespaceNotFoundInSchemasError
Hereda de XmlSchemaValidatorError. Se lanza en Schemas.item() cuando se solicita un namespace que no está registrado.
- Mensaje:
`Namespace ${namespace} does not exists in the schemas` - Métodos:
getNamespace(): string: devuelve el namespace buscado.static create(namespace: string): NamespaceNotFoundInSchemasError
SchemaLocationPartsNotEvenError
Hereda de XmlSchemaValidatorError. Se lanza en SchemaValidator.buildSchemas() y SchemaValidator.buildSchemasFromSchemaLocationValue() cuando el valor de xsi:schemaLocation contiene un número impar de tokens.
- Mensaje:
'The schemaLocation attribute does not have even parts' - Métodos:
getParts(): string[]: arreglo con los tokens extraídos.getPartsAsString(): string: tokens unidos por un espacio (parts.join(' ')).static create(parts: string[]): SchemaLocationPartsNotEvenError
XmlContentIsEmptyError
Hereda de XmlSchemaValidatorError. Se lanza en SchemaValidator.createFromString() cuando la cadena XML está vacía ('').
- Mensaje:
'The xml contents is an empty string' - Métodos:
static create(): XmlContentIsEmptyError
XmlContentIsInvalidError
Hereda de XmlSchemaValidatorError. Se lanza en SchemaValidator.createFromString() cuando el contenido no puede parsearse como XML.
- Mensaje:
`The xml contents cannot be loaded: ${previous.message}` - Métodos:
getPrevious(): Error: devuelve elSyntaxErrorcapturado al intentar parsear el XML.static create(previous: Error): XmlContentIsInvalidError
