Exceptions

Exceptions used by the Yangson library.

This module defines the following exceptions:

exception yangson.exceptions.AnnotationException(path: str)

Bases: YangsonException

Abstract class for exceptions related to metadata annotations.

exception yangson.exceptions.AnnotationTypeError(path: str, aname: str, msg: str)

Bases: AnnotationException

Type of annotation is incorrect.

exception yangson.exceptions.BadSchemaNodeType(qn: tuple[str, str], expected: str)

Bases: SchemaNodeException

A schema node is of a wrong type.

exception yangson.exceptions.BadYangLibraryData(message: str)

Bases: YangsonException

Broken YANG library data.

exception yangson.exceptions.CyclicImports

Bases: YangsonException

YANG modules are imported in a cyclic fashion.

exception yangson.exceptions.DefinitionNotFound(kw: str, name: str)

Bases: YangsonException

Requested definition does not exist.

exception yangson.exceptions.EndOfInput(parser: Parser)

Bases: ParserException

Unexpected end of input.

exception yangson.exceptions.FeaturePrerequisiteError(name: str, ns: str)

Bases: YangsonException

Pre-requisite feature is not supported.

exception yangson.exceptions.InstanceException(instance: InstanceNode, message: str)

Bases: YangsonException

Abstract class for exceptions related to operations on instance nodes.

exception yangson.exceptions.InstanceValueError(instance: InstanceNode, message: str)

Bases: InstanceException

The instance value is incompatible with the called method.

exception yangson.exceptions.InvalidArgument(arg: str)

Bases: YangsonException

The argument of a statement is invalid.

exception yangson.exceptions.InvalidFeatureExpression(parser: Parser)

Bases: ParserException

Invalid if-feature expression.

exception yangson.exceptions.InvalidKeyValue(value: int | Decimal | str | tuple[None])

Bases: YangsonException

List key or leaf-list value is invalid.

exception yangson.exceptions.InvalidLeafrefPath(qn: tuple[str, str])

Bases: SchemaNodeException

A leafref path is incorrect.

exception yangson.exceptions.InvalidSchemaPath(path: str)

Bases: YangsonException

Invalid schema or data path.

exception yangson.exceptions.InvalidXPath(parser: Parser)

Bases: ParserException

Exception to be raised for an invalid XPath expression.

exception yangson.exceptions.MissingAnnotationTarget(path: str, iname: str)

Bases: AnnotationException

Instance node that is being annotated doesn’t exist.

exception yangson.exceptions.MissingModule(name: str, rev: str = '')

Bases: YangsonException

Abstract exception class – a module is missing.

exception yangson.exceptions.MissingModuleNamespace(ns: str)

Bases: YangsonException

Abstract exception class – a module is missing.

exception yangson.exceptions.ModuleContentMismatch(found: str, expected: str)

Bases: YangsonException

Abstract exception class – unexpected module name or revision.

exception yangson.exceptions.ModuleNameMismatch(found: str, expected: str)

Bases: ModuleContentMismatch

Parsed module revision doesn’t match the expected revision.

exception yangson.exceptions.ModuleNotFound(name: str, rev: str = '')

Bases: MissingModule

A module or submodule registered in YANG library is not found.

exception yangson.exceptions.ModuleNotImplemented(name: str, rev: str = '')

Bases: MissingModule

A module is not implemented in the data model.

exception yangson.exceptions.ModuleNotImported(mod: str, mid: tuple[str, str])

Bases: YangsonException

Module is not imported.

exception yangson.exceptions.ModuleNotRegistered(name: str, rev: str = '')

Bases: MissingModule

A module is not registered in YANG library.

exception yangson.exceptions.ModuleRevisionMismatch(found: str, expected: str)

Bases: ModuleContentMismatch

Parsed module revision doesn’t match the expected revision.

exception yangson.exceptions.MultipleImplementedRevisions(module: str)

Bases: YangsonException

A module has multiple implemented revisions.

exception yangson.exceptions.NonDataNode(instance: InstanceNode, message: str)

Bases: InstanceException

Attempt to access an instance of non-data node (rpc/action/notification).

exception yangson.exceptions.NonexistentInstance(instance: InstanceNode, message: str)

Bases: InstanceException

Attempt to access an instance node that doesn’t exist.

exception yangson.exceptions.NonexistentSchemaNode(qn: tuple[str, str], name: str, ns: str = None)

Bases: SchemaNodeException

A schema node doesn’t exist.

exception yangson.exceptions.NotSupported(parser: Parser, feature: str)

Bases: ParserException

Exception to be raised for unimplemented XPath features.

exception yangson.exceptions.ParserException(parser: Parser)

Bases: YangsonException

Base class for parser exceptions.

exception yangson.exceptions.RawDataError(path: str)

Bases: YangsonException

Abstract exception class for errors in raw data.

exception yangson.exceptions.RawMemberError(path: str)

Bases: RawDataError

Object member in the raw value doesn’t exist in the schema.

exception yangson.exceptions.RawTypeError(path: str, expected: str)

Bases: RawDataError

Raw value is of an incorrect type.

exception yangson.exceptions.SchemaError(instance: InstanceNode, tag: str, message: str = None)

Bases: ValidationError

An instance violates a schema constraint.

exception yangson.exceptions.SchemaNodeException(qn: tuple[str, str])

Bases: YangsonException

Abstract exception class for schema node errors.

exception yangson.exceptions.SemanticError(instance: InstanceNode, tag: str, message: str = None)

Bases: ValidationError

An instance violates a semantic rule.

exception yangson.exceptions.StatementNotFound(parent: str, kw: str)

Bases: YangsonException

Required statement does not exist.

exception yangson.exceptions.UndefinedAnnotation(path: str, aname: str)

Bases: AnnotationException

Undefined annotation is used.

exception yangson.exceptions.UnexpectedInput(parser: Parser, expected: str = None)

Bases: ParserException

Unexpected input.

exception yangson.exceptions.UnknownPrefix(prefix: str, mid: tuple[str, str])

Bases: YangsonException

Unknown namespace prefix.

exception yangson.exceptions.ValidationError(instance: InstanceNode, tag: str, message: str = None)

Bases: YangsonException

Abstract exception class for instance validation errors.

exception yangson.exceptions.XPathTypeError(value: str)

Bases: YangsonException

The value of an XPath (sub)expression is of a wrong type.

exception yangson.exceptions.YangTypeError(instance: InstanceNode, tag: str, message: str = None)

Bases: ValidationError

A scalar value doesn’t match its expected type.

exception yangson.exceptions.YangsonException

Bases: Exception

Base class for all Yangson exceptions.

Error Tags

Exceptions related to validity of instance documents, i.e. instances of the SchemaError and SemanticError classes, have the tag attribute containing a semi-formal string identifying the specific error condition.

Below is the list of error tags used by the Yangson library. Some of them are defined in sec. 15 of [RFC7950] but Yangson also introduces a number of error tags on its own. Furthermore, error tags specific to a concrete data model can be defined using the error-app-tag statement in YANG, see sec. 7.5.4.2 of [RFC7950]. If they are present in the data model, Yangson also uses them.

data-not-unique

A unique constraint is violated, see sec. 7.8.3 of [RFC7950].

instance-required

An required instance referred to by a leafref or instance-identifier leaf is missing.

invalid-type

A leaf or leaf-list value has invalid type.

list-key-missing

A key instance is missing in a list entry.

member-not-allowed

An object member is not permitted by the schema.

missing-data

Data required by the schema are missing.

must-violation

A must constraint is violated, see sec. 7.5.3 of [RFC7950].

non-unique-key

Key values of a list instance are not unique.

repeated-leaf-list-values

Values of a leaf-list instance representing configuration are not unique.

too-few-elements

A min-elements constraint is violated, see sec. 7.7.5 of [RFC7950].

too-many-elements

A max-elements constraint is violated, see sec. 7.7.6 of [RFC7950].