Error Reference


Handling Errors

Stack Traces

Because SQLAthanor produces exceptions which inherit from the standard library, it leverages the same API for handling stack trace information. This means that it will be handled just like a normal exception in unit test frameworks, logging solutions, and other tools that might need that information.

Errors During Serialization

from sqlathanor.errors import SerializableAttributeError, \
  UnsupportedSerializationError, MaximumNestingExceededError

# For a SQLAlchemy Model Class named "User" and a model instance named "user".

try:
  as_csv = user.to_csv()
  as_json = user.to_json()
  as_yaml = user.to_yaml()
  as_dict = user.to_dict()
except SerializableAttributeError as error:
  # Handle the situation where "User" model class does not have any attributes
  # serializable to JSON.
  pass
except UnsupportedSerializationError as error:
  # Handle the situation where one of the "User" model attributes is of a data
  # type that does not support serialization.
  pass
except MaximumNestingExceededError as error:
  # Handle a situation where "user.to_json()" received max_nesting less than
  # current_nesting.
  #
  # This situation is typically an error on the programmer's part, since
  # SQLAthanor by default avoids this kind of situation.
  #
  # Best practice is simply to let this exception bubble up.
  raise error

Errors During De-Serialization

from sqlathanor.errors import DeserializableAttributeError, \
  CSVStructureError, DeserializationError, ValueDeserializationError, \
  ExtraKeysError, UnsupportedDeserializationError

# For a SQLAlchemy Model Class named "User" and a model instance named "user",
# with serialized data in "as_csv", "as_json", "as_yaml", and "as_dict" respectively.

try:
  user.update_from_csv(as_csv)
  user.update_from_json(as_json)
  user.update_from_yaml(as_yaml)
  user.update_from_dict(as_dict)

  new_user = User.new_from_csv(as_csv)
  new_user = User.new_from_json(as_json)
  new_user = User.new_from_yaml(as_yaml)
  new_user = User.new_from_dict(as_dict)
except DeserializableAttributeError as error:
  # Handle the situation where "User" model class does not have any attributes
  # de-serializable from the given format (CSV, JSON, YAML, or dict).
  pass
except DeserializationError as error:
  # Handle the situation where the serialized object ("as_csv", "as_json",
  # "as_yaml", "as_dict") cannot be parsed, for example because it is not
  # valid JSON, YAML, or dict.
  pass
except CSVStructureError as error:
  # Handle the situation where the structure of "as_csv" does not match the
  # expectation configured for the "User" model class.
  raise error
except ExtraKeysError as error:
  # Handle the situation where the serialized object ("as_json",
  # "as_yaml", "as_dict") may have unexpected keys/attributes and
  # the error_on_extra_keys argument is False.
  #
  # Applies to: *_from_json(), *_from_yaml(), and *_from_dict() methods
  pass
except ValueDeserializationError as error:
  # Handle the situation where an input value in the serialized object
  # raises an exception in the deserialization post-processing function.
  pass
except UnsupportedDeserializationError as error:
  # Handle the situation where the de-serialization process attempts to
  # assign a value to an attribute that does not support de-serialization.
  pass

SQLAthanor Errors

SQLAthanorError (from ValueError)

class SQLAthanorError[source]

Base error raised by SQLAthanor. Inherits from ValueError.


ConfigurationError (from SQLAthanorError)

class ConfigurationError[source]

Error raised when the serialization confirmation does not match expectations.


SQLAlchemySupportError (from SQLAthanorError)

class SQLAlchemySupportError[source]

Error raised when attempting to leverage a SQLAlchemy functionality that is not supported in your environment’s version of SQLAlchemy.


InvalidFormatError (from SQLAthanorError)

class InvalidFormatError[source]

Error raised when supplying a format that is not recognized by SQLAthanor.


SerializationError (from SQLAthanorError)

class SerializationError[source]

Error raised when something went wrong during serialization.


ValueSerializationError (from SerializationError)

class ValueSerializationError[source]

Error raised when an attribute value fails the serialization process.


SerializableAttributeError (from SerializationError)

class SerializableAttributeError[source]

Error raised when there are no serializable attributes on a model instance.


MaximumNestingExceededError (from SerializationError)

class MaximumNestingExceededError[source]

Error raised when the maximum permitted nesting is exceeded during serialization.


UnsupportedSerializationError (from SerializationError)

class UnsupportedSerializationError[source]

Error raised when attempting to serialize an attribute that does not support serialization.


DeserializationError (from SQLAthanorError)

class DeserializationError[source]

Error raised when something went wrong during de-serialization.


CSVStructureError (from DeserializationError)

class CSVStructureError[source]

Error raised when there is a mismatch between expected columns and found columns in CSV data.


JSONParseError (from DeserializationError)

class JSONParseError[source]

Error raised when something went wrong parsing input JSON data.


YAMLParseError (from DeserializationError)

class YAMLParseError[source]

Error raised when something went wrong parsing input YAML data.


DeserializableAttributeError (from DeserializationError)

class DeserializableAttributeError[source]

Error raised when there are no de-serializable attributes on a model instance or an inbound data source is empty.


ValueDeserializationError (from DeserializationError)

class ValueDeserializationError[source]

Error raised when an attribute value fails the de-serialization process.


UnsupportedValueTypeError (from DeserializationError)

class UnsupportedValueTypeError[source]

Error raised when a value type found in a serialized string is not supported.


UnsupportedDeserializationError (from DeserializationError)

class UnsupportedDeserializationError[source]

Error raised when attempting to de-serialize an attribute that does not support de-serialization.


ExtraKeyError (from DeserializationError)

class ExtraKeyError[source]

Error raised when an inbound object being de-serialized has extra (unrecognized) keys.


SQLAthanor Warnings

SQLAthanorWarning (from UserWarning)

class SQLAthanorWarning[source]

Base warning raised by SQLAthanor. Inherits from UserWarning.


MaximumNestingExceededWarning (from SQLAthanorWarning)

class MaximumNestingExceededWarning[source]

Warning raised when the maximum permitted nesting is exceeded during serialization.