Skip to content

Errors

This section contains the distilabel custom errors. Unlike exceptions, errors in distilabel are used to handle unexpected situations that can't be anticipated and that can't be handled in a controlled way.

DistilabelError

A mixin class for common functionality shared by all Distilabel-specific errors.

Attributes:

Name Type Description
message

A message describing the error.

page

An optional error code from PydanticErrorCodes enum.

Examples:

raise DistilabelUserError("This is an error message.")
This is an error message.

raise DistilabelUserError("This is an error message.", page="sections/getting_started/faq/")
This is an error message.
For further information visit 'https://distilabel.argilla.io/latest/sections/getting_started/faq/'
Source code in src/distilabel/errors.py
class DistilabelError:
    """A mixin class for common functionality shared by all Distilabel-specific errors.

    Attributes:
        message: A message describing the error.
        page: An optional error code from PydanticErrorCodes enum.

    Examples:
        ```python
        raise DistilabelUserError("This is an error message.")
        This is an error message.

        raise DistilabelUserError("This is an error message.", page="sections/getting_started/faq/")
        This is an error message.
        For further information visit 'https://distilabel.argilla.io/latest/sections/getting_started/faq/'
        ```
    """

    def __init__(self, message: str, *, page: Optional[str] = None) -> None:
        self.message = message
        self.page = page

    def __str__(self) -> str:
        if self.page is None:
            return self.message
        else:
            return f"{self.message}\n\nFor further information visit '{DISTILABEL_DOCS_URL}{self.page}'"

DistilabelUserError

Bases: DistilabelError, ValueError

ValueError that we can redirect to a given page in the documentation.

Source code in src/distilabel/errors.py
class DistilabelUserError(DistilabelError, ValueError):
    """ValueError that we can redirect to a given page in the documentation."""

    pass

DistilabelTypeError

Bases: DistilabelError, TypeError

TypeError that we can redirect to a given page in the documentation.

Source code in src/distilabel/errors.py
class DistilabelTypeError(DistilabelError, TypeError):
    """TypeError that we can redirect to a given page in the documentation."""

    pass

DistilabelNotImplementedError

Bases: DistilabelError, NotImplementedError

NotImplementedError that we can redirect to a given page in the documentation.

Source code in src/distilabel/errors.py
class DistilabelNotImplementedError(DistilabelError, NotImplementedError):
    """NotImplementedError that we can redirect to a given page in the documentation."""

    pass