Skip to content

Errors

API Status

Error documentation needs comprehensive coverage of all exception types.

Error Categories

[Overview of error types]

Exception Reference

relation_errors

This module provides the errors for the relation module.

Classes

DuplicateAttributeError

Bases: Exception

Attempt to setattr to an already existing attribute.

Source code in half_orm/relation_errors.py
class DuplicateAttributeError(Exception):
    """Attempt to setattr to an already existing attribute."""

ExpectedOneError

Bases: Exception

This exception is raised when get count differs from 1.

Source code in half_orm/relation_errors.py
3
4
5
6
7
8
9
class ExpectedOneError(Exception):
    """This exception is raised when get count differs from 1."""
    def __init__(self, relation, count):
        self.rel = relation
        self.count = count
        self.plural = '' if count == 0 else 's'
        Exception.__init__(self, f'Expected 1, got {self.count} tuple{self.plural}')

IsFrozenError

Bases: Exception

Class is frozen

Source code in half_orm/relation_errors.py
class IsFrozenError(Exception):
    """Class is frozen"""
    def __init__(self, cls, msg):
        super().__init__(
            f"ERROR! The class {cls} is forzen.\n"
            f"Use ho_unfreeze to add the '{msg}' attribute to it.")

NotASingletonError

Bases: Exception

The constraint do not define a singleton.

Raised from ExpectedOneError (err).

Source code in half_orm/relation_errors.py
class NotASingletonError(Exception):
    """The constraint do not define a singleton.

    Raised from ExpectedOneError (err).
    """
    def __init__(self, err):
        Exception.__init__(self, f'Not a singleton. Got {err.count} tuple{err.plural}')

UnknownAttributeError

Bases: Exception

Unknown attribute error

Source code in half_orm/relation_errors.py
class UnknownAttributeError(Exception):
    """Unknown attribute error"""
    def __init__(self, msg):
        super().__init__(f"ERROR! Unknown attribute: {msg}.")

WrongFkeyError

Bases: Exception

Raised when Fkeys contains a wrong name

Source code in half_orm/relation_errors.py
class WrongFkeyError(Exception):
    "Raised when Fkeys contains a wrong name"
    def __init__(self, cls, value):
        fkeys_list = "\n".join([f" - {fkey}" for fkey in cls._ho_fkeys.keys()])
        err = f"Can't find '{value}'!\n" \
            f"List of keys for {cls.__class__.__name__}:\n" \
            f"{fkeys_list}"
        super().__init__(err)

model_errors

This module provides the errors for the model module.

Classes

MalformedConfigFile

Bases: Exception

The config file is malformed.

The missing parameters are indicated in the error message.

Source code in half_orm/model_errors.py
class MalformedConfigFile(Exception):
    """The config file is malformed.

    The missing parameters are indicated in the error message.
    """
    def __init__(self, filename, msg, missing_param):
        self.filename = filename
        Exception.__init__(
            self,
            f"Malformed config file: {filename}\n{msg}: {missing_param}")

MissingConfigFile

Bases: Exception

The config file has not been found.

Source code in half_orm/model_errors.py
3
4
5
6
7
class MissingConfigFile(Exception):
    """The config file has not been found."""
    def __init__(self, filename):
        self.filename = filename
        Exception.__init__(self, f'Missing config file: {filename}')

MissingSchemaInName

Bases: Exception

The QRN should contain a schema name.

Source code in half_orm/model_errors.py
class MissingSchemaInName(Exception):
    """The QRN should contain a schema name."""
    def __init__(self, qrn):
        Exception.__init__(self, f"do you mean 'public.{qrn}'?")

UnknownRelation

Bases: Exception

The FQRN doesn't match any relation in the database.

Source code in half_orm/model_errors.py
class UnknownRelation(Exception):
    """The FQRN doesn't match any relation in the database."""
    def __init__(self, sfqrn):
        self.dbname = sfqrn[0]
        self.schema = sfqrn[1]
        self.relation = sfqrn[2]
        Exception.__init__(self, f"'{sfqrn[1]}.{sfqrn[2]}' does not exist in the database {sfqrn[0]}.")