Skip to content

xtr_console.exception

Every error this library raises.

All of them derive from :class:ConsoleError, so one except catches anything the console can go wrong with, and a narrower one handles a single cause. Each carries the data a caller needs as typed attributes rather than forcing a message to be parsed.

CommandSignatureError

CommandSignatureError(command_name: str, reason: str)

Bases: ConsoleError

A command is declared in a shape the console cannot call.

Record the command and what is wrong with its declaration.

ConsoleError

Bases: Exception

Base class for every error raised by this library.

Catch this to handle anything the console can go wrong with; catch a subclass to handle one cause. Every subclass carries the data a caller needs as typed attributes and composes its own message from them.

DuplicateCommandError

DuplicateCommandError(name: str, claimed_by: str)

Bases: ConsoleError

Two commands claim the same name or alias.

Record the contested name and the command already holding it.

EventLoopRunningError

EventLoopRunningError()

Bases: ConsoleError

A blocking run was started from code already running on an event loop.

Explain what to call instead.

InvalidCommandNameError

InvalidCommandNameError(name: str, reason: str)

Bases: ConsoleError

A command's name or alias cannot be typed on a command line.

Record the name and what is wrong with it.

InvalidCommandResultError

InvalidCommandResultError(command_name: str, result_type: str)

Bases: ConsoleError

A command returned something that is not an exit code.

Record the command and the type of what it returned.

InvalidDefaultError

InvalidDefaultError(question: str, default: str, choices: tuple[str, ...])

Bases: ConsoleError

A question's default is not one of the answers it accepts.

Record the question, its default and the answers it accepts.

MissingContainerError

MissingContainerError(command_name: str, parameters: tuple[str, ...])

Bases: ConsoleError

A command needs a dependency-injection container, and none is wired.

Record the command and the parameters only a container can fill.