Skip to content

errors

ArgumentError

Bases: ExternalError

Error with the value of a provided argument

Source code in /home/runner/work/arc/arc/arc/errors.py
class ArgumentError(ExternalError):
    """Error with the value of a provided argument"""

ConversionError

Bases: ArgumentError

Raised if a type conversion fails

Source code in /home/runner/work/arc/arc/arc/errors.py
class ConversionError(ArgumentError):
    """Raised if a type conversion fails"""

    def __init__(self, value: t.Any, message: str, details: t.Any | None = None):
        self.value = value
        self.details = details
        super().__init__(message)

ExternalError

Bases: ArcError

Errors that fire due to user / input errors

Source code in /home/runner/work/arc/arc/arc/errors.py
class ExternalError(ArcError):
    """Errors that fire due to user / input errors"""

InternalError

Bases: ArcError

Errors that fire due to development / internal errors. These will be noted to probably be bugs in production mode

Source code in /home/runner/work/arc/arc/arc/errors.py
class InternalError(ArcError):
    """Errors that fire due to development / internal errors.
    These will be noted to probably be bugs in production mode"""

    def fmt(self, ctx: Context) -> str:
        message = (
            f"{colorize('ERROR:', ctx.config.present.color.error, fx.BOLD)} {str(self)}\n\n"
            "This is probably a bug, please report it to the maintainer"
        )

        if link := ctx.config.links.bug:
            message += f": {link}"

        return message

UsageError

Bases: ExternalError

Indicates that the command was used incorrectly. If a command is provided, the command's usage will be printed, along with the provided error message

Source code in /home/runner/work/arc/arc/arc/errors.py
class UsageError(ExternalError):
    """Indicates that the command was used incorrectly.
    If a command is provided, the command's usage will be printed,
    along with the provided error message"""

    def __init__(self, message: str, command: Command = None):
        self.message = message
        self.command = command

    def fmt(self, ctx: Context) -> str:
        return f"{self.usage()}{self.message}"

    def usage(self) -> str:
        if self.command:
            return self.command.doc.usage() + "\n"

        return ""

exit(code=0, message=None)

Exits the application with code. Optionally recieves a message that will be written to stderr before exiting

Source code in /home/runner/work/arc/arc/arc/errors.py
def exit(code: int = 0, message: str | None = None) -> t.NoReturn:
    """Exits the application with `code`.
    Optionally recieves a `message` that will be written
    to stderr before exiting"""
    raise Exit(code, message)