Module astrapy.exceptions.table_exceptions

Classes

class TableInsertManyException (inserted_ids: list[Any],
inserted_id_tuples: list[tuple[Any, ...]],
exceptions: Sequence[Exception])
Expand source code
@dataclass
class TableInsertManyException(DataAPIException):
    """
    An exception occurring within an insert_many (an operation that can span
    several requests). As such, it represents both the root error(s) that happened
    and information on the portion of the row that were successfully inserted.

    The behaviour of insert_many (concurrency and the `ordered` setting) make it
    possible that more than one "root errors" are collected.

    Attributes:
        inserted_ids: a list of the row IDs that have been successfully inserted,
            in the form of a dictionary matching the table primary key).
        inserted_id_tuples: the same information as for `inserted_ids` (in the same
            order), but in form of a tuples for each ID.
        exceptions: a list of the root exceptions leading to this error. The list,
            under normal circumstances, is not empty.
    """

    inserted_ids: list[Any]
    inserted_id_tuples: list[tuple[Any, ...]]
    exceptions: Sequence[Exception]

    def __str__(self) -> str:
        num_ids = len(self.inserted_ids)
        if self.exceptions:
            exc_desc: str
            excs_strs = [exc.__str__() for exc in self.exceptions[:8]]
            if len(self.exceptions) > 8:
                exc_desc = ", ".join(excs_strs) + " ... (more exceptions)"
            else:
                exc_desc = ", ".join(excs_strs)
            return (
                f"{self.__class__.__name__}({exc_desc} [with {num_ids} inserted ids])"
            )
        else:
            return f"{self.__class__.__name__}()"

An exception occurring within an insert_many (an operation that can span several requests). As such, it represents both the root error(s) that happened and information on the portion of the row that were successfully inserted.

The behaviour of insert_many (concurrency and the ordered setting) make it possible that more than one "root errors" are collected.

Attributes

inserted_ids
a list of the row IDs that have been successfully inserted, in the form of a dictionary matching the table primary key).
inserted_id_tuples
the same information as for inserted_ids (in the same order), but in form of a tuples for each ID.
exceptions
a list of the root exceptions leading to this error. The list, under normal circumstances, is not empty.

Ancestors

Instance variables

var exceptions : Sequence[Exception]

The type of the None singleton.

var inserted_id_tuples : list[tuple[typing.Any, ...]]

The type of the None singleton.

var inserted_ids : list[typing.Any]

The type of the None singleton.

class TooManyRowsToCountException (text: str, *, server_max_count_exceeded: bool)
Expand source code
@dataclass
class TooManyRowsToCountException(DataAPIException):
    """
    A `count_documents()` operation on a table failed because of the excessive amount
    of rows to count.

    Attributes:
        text: a text message about the exception.
    """

    text: str
    server_max_count_exceeded: bool

    def __init__(
        self,
        text: str,
        *,
        server_max_count_exceeded: bool,
    ) -> None:
        super().__init__(text)
        self.text = text
        self.server_max_count_exceeded = server_max_count_exceeded

A count_documents() operation on a table failed because of the excessive amount of rows to count.

Attributes

text
a text message about the exception.

Ancestors

Instance variables

var server_max_count_exceeded : bool

The type of the None singleton.

var text : str

The type of the None singleton.