Source code for cookiecutter.exceptions

"""All exceptions used in the Cookiecutter code base are defined here."""

[docs] class CookiecutterException(Exception): """ Base exception class. All Cookiecutter-specific exceptions should subclass this class. """
[docs] class NonTemplatedInputDirException(CookiecutterException): """ Exception for when a project's input dir is not templated. The name of the input directory should always contain a string that is rendered to something else, so that input_dir != output_dir. """
[docs] class UnknownTemplateDirException(CookiecutterException): """ Exception for ambiguous project template directory. Raised when Cookiecutter cannot determine which directory is the project template, e.g. more than one dir appears to be a template dir. """
# unused locally
[docs] class MissingProjectDir(CookiecutterException): """ Exception for missing generated project directory. Raised during cleanup when remove_repo() can't find a generated project directory inside of a repo. """
# unused locally
[docs] class ConfigDoesNotExistException(CookiecutterException): """ Exception for missing config file. Raised when get_config() is passed a path to a config file, but no file is found at that path. """
[docs] class InvalidConfiguration(CookiecutterException): """ Exception for invalid configuration file. Raised if the global configuration file is not valid YAML or is badly constructed. """
[docs] class UnknownRepoType(CookiecutterException): """ Exception for unknown repo types. Raised if a repo's type cannot be determined. """
[docs] class VCSNotInstalled(CookiecutterException): """ Exception when version control is unavailable. Raised if the version control system (git or hg) is not installed. """
[docs] class ContextDecodingException(CookiecutterException): """ Exception for failed JSON decoding. Raised when a project's JSON context file can not be decoded. """
[docs] class OutputDirExistsException(CookiecutterException): """ Exception for existing output directory. Raised when the output directory of the project exists already. """
[docs] class InvalidModeException(CookiecutterException): """ Exception for incompatible modes. Raised when cookiecutter is called with both `no_input==True` and `replay==True` at the same time. """
[docs] class FailedHookException(CookiecutterException): """ Exception for hook failures. Raised when a hook script fails. """
[docs] class UndefinedVariableInTemplate(CookiecutterException): """ Exception for out-of-scope variables. Raised when a template uses a variable which is not defined in the context. """ def __init__(self, message, error, context): """Exception for out-of-scope variables.""" self.message = message self.error = error self.context = context def __str__(self): """Text representation of UndefinedVariableInTemplate.""" return ( f"{self.message}. " f"Error message: {self.error.message}. " f"Context: {self.context}" )
[docs] class UnknownExtension(CookiecutterException): """ Exception for un-importable extension. Raised when an environment is unable to import a required extension. """
[docs] class RepositoryNotFound(CookiecutterException): """ Exception for missing repo. Raised when the specified cookiecutter repository doesn't exist. """
[docs] class RepositoryCloneFailed(CookiecutterException): """ Exception for un-cloneable repo. Raised when a cookiecutter template can't be cloned. """
[docs] class InvalidZipRepository(CookiecutterException): """ Exception for bad zip repo. Raised when the specified cookiecutter repository isn't a valid Zip archive. """