diff options
Diffstat (limited to 'dodai/exception.py')
-rw-r--r-- | dodai/exception.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/dodai/exception.py b/dodai/exception.py index 5af10b4..23302c7 100644 --- a/dodai/exception.py +++ b/dodai/exception.py | |||
@@ -16,6 +16,7 @@ | |||
16 | # along with Dodai. If not, see <http://www.gnu.org/licenses/>. | 16 | # along with Dodai. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | from dodai.tools import list_to_english | 18 | from dodai.tools import list_to_english |
19 | from dodai.tools import quote_list | ||
19 | 20 | ||
20 | class DodaiException(Exception): | 21 | class DodaiException(Exception): |
21 | 22 | ||
@@ -234,3 +235,55 @@ class UnknownDatabaseConnectionException( | |||
234 | 235 | ||
235 | def __str__(self): | 236 | def __str__(self): |
236 | return self.msg | 237 | return self.msg |
238 | |||
239 | |||
240 | class InvalidConfigParser(DodaiException): | ||
241 | """Exception raised when an invalid parser is registered in the | ||
242 | dodai.config.ConfigFiles object. | ||
243 | |||
244 | """ | ||
245 | MESSAGE = "The parser object '{name}' that you were trying to register "\ | ||
246 | "is not a valid parser object. Please make sure that this "\ | ||
247 | "object contains all of the following methods: {methods}" | ||
248 | |||
249 | def __init__(self, required_methods, name): | ||
250 | self.msg = self._build_message(required_methods, name) | ||
251 | |||
252 | def _build_message(self, required_methods, name): | ||
253 | methods = quote_list(required_methods) | ||
254 | return self.MESSAGE.format(methods=methods, name=name) | ||
255 | |||
256 | def __str__(self): | ||
257 | return self.msg | ||
258 | |||
259 | |||
260 | class FileDoesNotExist(DodaiException): | ||
261 | """Exception raised when a file does not exist. | ||
262 | |||
263 | """ | ||
264 | MESSAGE = "The file: '{file_}' does not exist." | ||
265 | |||
266 | def __init__(self, filepath): | ||
267 | self.msg = self._build_message(filepath) | ||
268 | |||
269 | def _build_message(self, filepath): | ||
270 | return self.MESSAGE.format(file_=filepath) | ||
271 | |||
272 | def __str__(self): | ||
273 | return self.msg | ||
274 | |||
275 | |||
276 | class FileIsDirectory(DodaiException): | ||
277 | """Exception raised when a file is a directory. | ||
278 | |||
279 | """ | ||
280 | MESSAGE = "The file: '{file_}' is a directory." | ||
281 | |||
282 | def __init__(self, filepath): | ||
283 | self.msg = self._build_message(filepath) | ||
284 | |||
285 | def _build_message(self, filepath): | ||
286 | return self.MESSAGE.format(file_=filepath) | ||
287 | |||
288 | def __str__(self): | ||
289 | return self.msg | ||