hermes.model.error
==================

.. py:module:: hermes.model.error


Exceptions
----------

.. autoapisummary::

   hermes.model.error.HermesValidationError
   hermes.model.error.HermesCacheError
   hermes.model.error.HermesMergeError


Module Contents
---------------

.. py:exception:: HermesValidationError

   Bases: :py:obj:`Exception`


   This exception should be raised when an error occurs during input validation (e.g., during harvest).

   To be able to track and fix the error, you should use this in conjunction with the original exception if applicable:

   .. code:: python

       try:
            validate_some_data(src_file)
       except ValueError as e:
           raise HermesValidationError(src_file) from e


.. py:exception:: HermesCacheError

   Bases: :py:obj:`Exception`


   This exception should be raised when interacting with the model context.
   # TODO Change class name and docstring if we decide to call it differently
   # TODO in https://github.com/softwarepub/hermes/issues/392.

   To be able to track and fix the error, you should use this in conjunction with the original exception if applicable:

   .. code:: python

       try:
            context[term]
       except ValueError as e:
           raise HermesCacheError(term) from e


.. py:exception:: HermesMergeError(path: list[Union[str, int]], old_value: Any, new_value: Any, **kwargs)

   Bases: :py:obj:`Exception`


   This exception should be raised when there is an error during a merge / set operation.

   .. attribute:: path

      The path where the merge error occurred.

      :type: list[str | int]

   .. attribute:: old_value

      Old value that was stored at `path`.

      :type: Any

   .. attribute:: new_value

      New value that was to be assigned .

      :type: Any

   .. attribute:: tag

      Tag data for the new value.


