forked from cookiecutter/cookiecutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.py
163 lines (108 loc) · 3.79 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""All exceptions used in the Cookiecutter code base are defined here."""
class CookiecutterException(Exception):
"""
Base exception class.
All Cookiecutter-specific exceptions should subclass this class.
"""
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.
"""
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
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
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.
"""
class InvalidConfiguration(CookiecutterException):
"""
Exception for invalid configuration file.
Raised if the global configuration file is not valid YAML or is
badly constructed.
"""
class UnknownRepoType(CookiecutterException):
"""
Exception for unknown repo types.
Raised if a repo's type cannot be determined.
"""
class VCSNotInstalled(CookiecutterException):
"""
Exception when version control is unavailable.
Raised if the version control system (git or hg) is not installed.
"""
class ContextDecodingException(CookiecutterException):
"""
Exception for failed JSON decoding.
Raised when a project's JSON context file can not be decoded.
"""
class OutputDirExistsException(CookiecutterException):
"""
Exception for existing output directory.
Raised when the output directory of the project exists already.
"""
class InvalidModeException(CookiecutterException):
"""
Exception for incompatible modes.
Raised when cookiecutter is called with both `no_input==True` and
`replay==True` at the same time.
"""
class FailedHookException(CookiecutterException):
"""
Exception for hook failures.
Raised when a hook script fails.
"""
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}"
)
class UnknownExtension(CookiecutterException):
"""
Exception for un-importable extension.
Raised when an environment is unable to import a required extension.
"""
class RepositoryNotFound(CookiecutterException):
"""
Exception for missing repo.
Raised when the specified cookiecutter repository doesn't exist.
"""
class RepositoryCloneFailed(CookiecutterException):
"""
Exception for un-cloneable repo.
Raised when a cookiecutter template can't be cloned.
"""
class InvalidZipRepository(CookiecutterException):
"""
Exception for bad zip repo.
Raised when the specified cookiecutter repository isn't a valid
Zip archive.
"""