Custom exceptions

Custom exception classes used throughout dsch.

exception dsch.exceptions.AutodetectBackendError(storage_path)

Exception raised when backend autodetection fails.

exception dsch.exceptions.DschError

Base class for custom exceptions raised by dsch.

All dsch-specific exceptions are derived from this class.

exception dsch.exceptions.IncompatibleNodesError(hash1, hash2)

Exception used when node operations fail due to incompatible schemas.

exception dsch.exceptions.InvalidSchemaError(expected_hash, got_hash)

Exception used when an invalid/incompatible schema is used.

exception dsch.exceptions.NodeEmptyError

Exception indicating an empty data node.

This exception is raised when requesting a data node’s value fails because the node is empty. In that case, the value is undefined.

exception dsch.exceptions.ResetSubnodeError(item_id)

Exception raised when trying to re-set a data sub-node.

exception dsch.exceptions.SubnodeValidationError(location)

Exception used when validation fails for a subnode.

Validation failure always raises ValidationError. However, this only indicates which check has failed (e.g. string length exceeded), but not for which field this has occured.

This class uses exception chaining to recursively determine the full name and path of the affected data node, which is provided via node_path().

node_path()

Recursively determine the path of the node failing validation.

Returns:Full name and path of the node that failed validation.
Return type:str
original_cause()

Get the exception originally causing the chain.

This recursively follows the exception chain back to the original ValidationError that further describes the problem.

Returns:Original cause exception.
Return type:ValidationError
exception dsch.exceptions.ValidationError(message, expected, got=None)

Exception used when a schema node’s validation fails.

The message should indicate the kind of validation error and mention the constraint that was not met (e.g. ‘Maximum length exceeded.’). This message may be directly shown to users. For more information, expected contains a representation of the constraint (e.g. the maximum valid length) and got is the actual value determined for the given data, if applicable.

Variables:
  • message (str) – Human-readable error message.
  • expected – Expected, i.e. valid value.
  • got – Actual, i.e. invalid value.