Skip to content

Exceptions

aana.exceptions

BaseException

BaseException(**kwargs)

Bases: Exception

Base class for SDK exceptions.

Source code in aana/exceptions/core.py
def __init__(self, **kwargs: Any) -> None:
    """Initialise Exception."""
    super().__init__()
    self.extra = kwargs

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

aana.exceptions.runtime

InferenceException

InferenceException(model_name, message=None)

Bases: BaseException

Exception raised when there is an error during inference.

PARAMETER DESCRIPTION
model_name

name of the model that caused the exception

TYPE: str

message

the message to display

TYPE: str DEFAULT: None

Source code in aana/exceptions/runtime.py
def __init__(self, model_name: str, message: str | None = None):
    """Initialize the exception.

    Args:
        model_name (str): name of the model that caused the exception
        message (str): the message to display
    """
    message = message or f"Inference failed for model: {model_name}"
    super().__init__(
        model_name=model_name,
        message=message,
    )
    self.model_name = model_name
    self.message = message

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

PromptTooLongException

PromptTooLongException(prompt_len, max_len)

Bases: BaseException

Exception raised when the prompt is too long.

ATTRIBUTE DESCRIPTION
prompt_len

the length of the prompt in tokens

TYPE: int

max_len

the maximum allowed length of the prompt in tokens

TYPE: int

PARAMETER DESCRIPTION
prompt_len

the length of the prompt in tokens

TYPE: int

max_len

the maximum allowed length of the prompt in tokens

TYPE: int

Source code in aana/exceptions/runtime.py
def __init__(self, prompt_len: int, max_len: int):
    """Initialize the exception.

    Args:
        prompt_len (int): the length of the prompt in tokens
        max_len (int): the maximum allowed length of the prompt in tokens
    """
    super().__init__(prompt_len=prompt_len, max_len=max_len)
    self.prompt_len = prompt_len
    self.max_len = max_len

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

EndpointNotFoundException

EndpointNotFoundException(target, endpoint)

Bases: BaseException

Exception raised when an endpoint is not found.

ATTRIBUTE DESCRIPTION
target

the name of the target deployment

TYPE: str

endpoint

the endpoint path

TYPE: str

PARAMETER DESCRIPTION
target

the name of the target deployment

TYPE: str

endpoint

the endpoint path

TYPE: str

Source code in aana/exceptions/runtime.py
def __init__(self, target: str, endpoint: str):
    """Initialize the exception.

    Args:
        target (str): the name of the target deployment
        endpoint (str): the endpoint path
    """
    super().__init__(target=target, endpoint=endpoint)
    self.target = target
    self.endpoint = endpoint

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

TooManyRequestsException

TooManyRequestsException(rate_limit, rate_duration)

Bases: BaseException

Exception raised when calling a rate-limited resource too often.

ATTRIBUTE DESCRIPTION
rate_limit

The limit amount.

TYPE: int

rate_duration

The duration for the limit in seconds.

TYPE: float

PARAMETER DESCRIPTION
rate_limit

The limit amount.

TYPE: int

rate_duration

The duration for the limit in seconds.

TYPE: float

Source code in aana/exceptions/runtime.py
def __init__(self, rate_limit: int, rate_duration: float):
    """Constructor.

    Args:
        rate_limit (int): The limit amount.
        rate_duration (float): The duration for the limit in seconds.
    """
    super().__init__(rate_limit=rate_limit, rate_duration=rate_duration)
    self.rate_limit = rate_limit
    self.rate_duration = rate_duration

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

HandlerAlreadyRegisteredException

HandlerAlreadyRegisteredException()

Bases: BaseException

Exception raised when registering a handler that is already registered.

Source code in aana/exceptions/runtime.py
def __init__(self):
    """Constructor."""
    super().__init__()

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

HandlerNotRegisteredException

HandlerNotRegisteredException()

Bases: BaseException

Exception removing a handler that has not been registered.

Source code in aana/exceptions/runtime.py
def __init__(self):
    """Constructor."""
    super().__init__()

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

EmptyMigrationsException

EmptyMigrationsException(**kwargs)

Bases: BaseException

Exception raised when there are no migrations to apply.

Source code in aana/exceptions/core.py
def __init__(self, **kwargs: Any) -> None:
    """Initialise Exception."""
    super().__init__()
    self.extra = kwargs

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

DeploymentException

Bases: Exception

Base exception for deployment errors.

InsufficientResources

Bases: DeploymentException

Exception raised when there are insufficient resources for a deployment.

FailedDeployment

Bases: DeploymentException

Exception raised when there is an error during deployment.

UploadedFileNotFound

UploadedFileNotFound(filename)

Bases: Exception

Exception raised when the uploaded file is not found.

PARAMETER DESCRIPTION
filename

the name of the file that was not found

TYPE: str

Source code in aana/exceptions/runtime.py
def __init__(self, filename: str):
    """Initialize the exception.

    Args:
        filename (str): the name of the file that was not found
    """
    super().__init__()
    self.filename = filename

InvalidWebhookEventType

InvalidWebhookEventType(event_type)

Bases: BaseException

Exception raised when an invalid webhook event type is provided.

PARAMETER DESCRIPTION
event_type

the invalid event type

TYPE: str

Source code in aana/exceptions/runtime.py
def __init__(self, event_type: str):
    """Initialize the exception.

    Args:
        event_type (str): the invalid event type
    """
    super().__init__(event_type=event_type)
    self.event_type = event_type

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

aana.exceptions.io

ImageReadingException

ImageReadingException(image)

Bases: BaseException

Exception raised when there is an error reading an image.

ATTRIBUTE DESCRIPTION
image

the image that caused the exception

TYPE: Image

PARAMETER DESCRIPTION
image

the image that caused the exception

TYPE: Image

Source code in aana/exceptions/io.py
def __init__(self, image: "Image"):
    """Initialize the exception.

    Args:
        image (Image): the image that caused the exception
    """
    super().__init__(image=image)
    self.image = image

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

AudioReadingException

AudioReadingException(audio)

Bases: BaseException

Exception raised when there is an error reading an audio.

ATTRIBUTE DESCRIPTION
audio

the audio that caused the exception

TYPE: Audio

PARAMETER DESCRIPTION
audio

the audio that caused the exception

TYPE: Audio

Source code in aana/exceptions/io.py
def __init__(self, audio: "Audio"):
    """Initialize the exception.

    Args:
        audio (Audio): the audio that caused the exception
    """
    super().__init__(audio=audio)
    self.audio = audio

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

DownloadException

DownloadException(url, msg='')

Bases: BaseException

Exception raised when there is an error downloading a file.

ATTRIBUTE DESCRIPTION
url

the URL of the file that caused the exception

TYPE: str

PARAMETER DESCRIPTION
url

the URL of the file that caused the exception

TYPE: str

msg

the error message

TYPE: str DEFAULT: ''

Source code in aana/exceptions/io.py
def __init__(self, url: str, msg: str = ""):
    """Initialize the exception.

    Args:
        url (str): the URL of the file that caused the exception
        msg (str): the error message
    """
    super().__init__(url=url)
    self.url = url
    self.msg = msg

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

VideoException

VideoException(video)

Bases: BaseException

Exception raised when working with videos.

ATTRIBUTE DESCRIPTION
video

the video that caused the exception

TYPE: Video

PARAMETER DESCRIPTION
video

the video that caused the exception

TYPE: Video

Source code in aana/exceptions/io.py
def __init__(self, video: "Video"):
    """Initialize the exception.

    Args:
        video (Video): the video that caused the exception
    """
    super().__init__(video=video)
    self.video = video

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

VideoReadingException

VideoReadingException(video)

Bases: VideoException

Exception raised when there is an error reading a video.

ATTRIBUTE DESCRIPTION
video

the video that caused the exception

TYPE: Video

PARAMETER DESCRIPTION
video

the video that caused the exception

TYPE: Video

Source code in aana/exceptions/io.py
def __init__(self, video: "Video"):
    """Initialize the exception.

    Args:
        video (Video): the video that caused the exception
    """
    super().__init__(video=video)
    self.video = video

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

VideoTooLongException

VideoTooLongException(video, video_len, max_len)

Bases: BaseException

Exception raised when the video is too long.

ATTRIBUTE DESCRIPTION
video

the video that caused the exception

TYPE: Video

video_len

the length of the video in seconds

TYPE: float

max_len

the maximum allowed length of the video in seconds

TYPE: float

PARAMETER DESCRIPTION
video

the video that caused the exception

TYPE: Video

video_len

the length of the video in seconds

TYPE: float

max_len

the maximum allowed length of the video in seconds

TYPE: float

Source code in aana/exceptions/io.py
def __init__(self, video: "Video", video_len: float, max_len: float):
    """Initialize the exception.

    Args:
        video (Video): the video that caused the exception
        video_len (float): the length of the video in seconds
        max_len (float): the maximum allowed length of the video in seconds
    """
    super().__init__(video=video, video_len=video_len, max_len=max_len)
    self.video = video
    self.video_len = video_len
    self.max_len = max_len

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

aana.exceptions.db

NotFoundException

NotFoundException(table_name, id)

Bases: BaseException

Raised when an item searched by id is not found.

PARAMETER DESCRIPTION
table_name

the name of the table being queried.

TYPE: str

id

the id of the item to be retrieved.

TYPE: int | MediaId

Source code in aana/exceptions/db.py
def __init__(self, table_name: str, id: int | MediaId):  # noqa: A002
    """Constructor.

    Args:
        table_name (str): the name of the table being queried.
        id (int | MediaId): the id of the item to be retrieved.
    """
    super().__init__(table=table_name, id=id)
    self.table_name = table_name
    self.id = id
    self.http_status_code = 404

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)

MediaIdAlreadyExistsException

MediaIdAlreadyExistsException(table_name, media_id)

Bases: BaseException

Raised when a media_id already exists.

PARAMETER DESCRIPTION
table_name

the name of the table being queried.

TYPE: str

media_id

the id of the item to be retrieved.

TYPE: MediaId

Source code in aana/exceptions/db.py
def __init__(self, table_name: str, media_id: MediaId):
    """Constructor.

    Args:
        table_name (str): the name of the table being queried.
        media_id (MediaId): the id of the item to be retrieved.
    """
    super().__init__(table=table_name, id=media_id)
    self.table_name = table_name
    self.media_id = media_id

get_data

get_data()

Get the data to be returned to the client.

RETURNS DESCRIPTION
dict[str, Any]

Dict[str, Any]: data to be returned to the client

Source code in aana/exceptions/core.py
def get_data(self) -> dict[str, Any]:
    """Get the data to be returned to the client.

    Returns:
        Dict[str, Any]: data to be returned to the client
    """
    data = self.extra.copy()
    return data

add_extra

add_extra(data)

Add extra data to the exception.

This data will be returned to the user as part of the response.

How to use: in the exception handler, add the extra data to the exception and raise it again.

Example
try:
    ...
except BaseException as e:
    e.add_extra({'extra_key': 'extra_value'})
    raise e
PARAMETER DESCRIPTION
data

dictionary containing the extra data

TYPE: dict[str, Any]

Source code in aana/exceptions/core.py
def add_extra(self, data: dict[str, Any]) -> None:
    """Add extra data to the exception.

    This data will be returned to the user as part of the response.

    How to use: in the exception handler, add the extra data to the exception and raise it again.

    Example:
        ```
        try:
            ...
        except BaseException as e:
            e.add_extra({'extra_key': 'extra_value'})
            raise e
        ```

    Args:
        data (dict[str, Any]): dictionary containing the extra data
    """
    self.extra.update(data)