Skip to content

Codes and Exceptions

Machine-readable warning and error codes.

Kept free of dependencies, and outside the model package, so that xmas_core.exceptions can attach a code to every exception without importing the model layer. Importing a submodule runs its parent package's __init__, so while this lived in model/ an exceptions import pulled in model.base - and model.base reaches back to exceptions, which is a cycle.

A member's name is the machine-readable token: what a consumer branches on, what a migration report serialises and what the rule file writes. Its value is the German label.

ErrorCode

Bases: Enum

An error: the operation failed.

WarnCode

Bases: Enum

A warning: the operation continued past it.

exceptions

Exceptions raised by xmas-core.

Every exception inherits from BaseError and carries a machine-readable code from ErrorCode, so a downstream consumer can branch on the cause without matching on message text:

try:
    collection = codec.read("plan.gml")
except BaseError as e:
    logger.error("%s: %s", e.code.name, e)

Errors that replace a bare ValueError raised by an earlier release also inherit ValueError, so existing except ValueError handlers keep working.

AppschemaNotFoundError

Bases: BaseError, ValueError

No supported application schema could be resolved from the data.

BaseError

Bases: Exception

Base class for every error raised by xmas-core.

DatasourceError

Bases: BaseError, ValueError

The datasource could not be used at all.

DuplicateGmlIdError

Bases: XMLParseError

The document uses the same gml:id for more than one feature.

A gml:id is an xsd:ID and so unique within a document. Where it is not, every #GML_<id> and urn:uuid:<id> reference to it names two features at once, and which of them was meant cannot be recovered.

ForbiddenDoctypeError

Bases: XMLParseError

The document carries a DOCTYPE.

XPlanGML never declares one. Entity references are left unexpanded by the hardened parser, so accepting a DTD would mean silently dropping element text.

InvalidReferenceError

Bases: BaseError, ValueError

A feature reference cannot be used where it was found.

Raised while reading GML for a reference that is neither an intra-document UUID nor an absolute URI, and while writing the coretable for an external reference, which has no row to point at.

JsonFGParseError

Bases: BaseError, ValueError

The datasource does not hold readable JSON.

RemoteFetchError

Bases: DatasourceError

A remote datasource could not be retrieved.

SRSNotFoundError

Bases: BaseError, ValueError

No spatial reference system could be determined for the data.

UnsupportedDatasourceError

Bases: DatasourceError

The datasource names a location this package refuses to open.

Raised for GDAL virtual filesystem paths (/vsicurl/, /vsizip/, ...), for URL schemes other than http/https, and for a remote URL while remote access is disabled.

UnsupportedFeatureError

Bases: BaseError

The source document holds a feature this package cannot migrate.

Raised for an RP_Plan: there is no mapping to a later XPlanung version, and the rest of the document cannot be migrated without it. An earlier release called sys.exit(1) from inside the rule instead, which no library caller could handle.

UnsupportedRootElementError

Bases: XMLParseError

The document's root element is not one this package reads.

XMLParseError

Bases: BaseError, ValueError

The document is not well-formed XML, or is XML this package refuses to parse.