Skip to content

xtr_maker.exception

Every error this library raises.

All of them derive from :class:MakerError, so one except catches anything that can stop a maker, and a narrower one handles one cause. Each carries the data a caller needs as typed attributes rather than forcing a message to be parsed.

AppPackageNotFoundError

AppPackageNotFoundError(root_package: str, project_dir: str)

Bases: MakerError

The application package the makers write into, not found by the import system.

Raised the first time a maker needs the package, never while the container is built, so the console keeps running and the message can say which setting to change.

Attributes:

  • root_package (str) –

    The package that was looked for.

  • project_dir (str) –

    The project the makers write into.

Record the package that was looked for, and the project it was looked for from.

GeneratedSourceError

GeneratedSourceError(template: str, reason: str, line: int | None = None)

Bases: MakerError

Python source rendered from a template that does not parse.

A template is checked every time it renders, so a broken one — or a value that broke it — is reported against the template, never written into the application for the next import to trip over.

Attributes:

  • template (str) –

    The template that rendered the source.

  • reason (str) –

    What the parser reported.

  • line (int | None) –

    The line of the rendered source it reported, when it named one.

Record the template, the parser's message and the line it pointed at.

InvalidArgumentError

Bases: MakerError, ValueError

A configuration value the makers cannot work with.

Also a :class:ValueError, so code catching that keeps working.

InvalidClassNameError

InvalidClassNameError(name: str, reason: str)

Bases: MakerError, ValueError

A name typed for a class that cannot become one.

Raised before anything is rendered, so a person is asked again rather than handed a file that does not import. Also a :class:ValueError, which is what a question's validator raises to have the question asked again.

Attributes:

  • name (str) –

    The name as it was typed.

  • reason (str) –

    Why it cannot be used.

Record the name and why it was refused.

MakerError

Bases: Exception

Base class for every error raised by this library.

Catch this to handle anything that can stop a maker from writing its files; 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.

TargetExistsError

TargetExistsError(path: str)

Bases: MakerError, FileExistsError

A file a maker would write that already exists, or is already about to be written.

Makers never overwrite: code someone wrote, or edited after a maker wrote it, is theirs. The error is raised when the file is queued, before anything is written, so a maker writing several files writes none of them.

Also a :class:FileExistsError, so code catching that keeps working.

Attributes:

  • path (str) –

    The file, relative to the project directory.

Record the file that is in the way.

UnsafePathError

UnsafePathError(path: str, reason: str)

Bases: MakerError, OSError

A path a maker was asked to write that lies outside the project, or is a symbolic link.

A name typed at a prompt ends up in a path, so every path is checked before a byte is written: one climbing out of the project, or a link pointing anywhere, is refused rather than followed.

Also an :class:OSError, so code catching filesystem failures keeps working.

Attributes:

  • path (str) –

    The path as it was given.

  • reason (str) –

    Why it was refused.

Record the path and why it was refused.