This repository was archived by the owner on May 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathexceptions.py
More file actions
44 lines (30 loc) · 1.3 KB
/
exceptions.py
File metadata and controls
44 lines (30 loc) · 1.3 KB
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
# Exception hierarchy for chef
# Copyright (c) 2010 Noah Kantrowitz <noah@coderanger.net>
class ChefError(Exception):
"""Top-level Chef error."""
class ChefServerError(ChefError):
"""An error from a Chef server. May include a HTTP response code."""
def __init__(self, message, code=None):
self.raw_message = message
if isinstance(message, list):
message = ', '.join(m for m in message if m)
super(ChefError, self).__init__(message)
self.code = code
@staticmethod
def from_error(message, code=None):
cls = {
404: ChefServerNotFoundError,
}.get(code, ChefServerError)
return cls(message, code)
class ChefServerNotFoundError(ChefServerError):
"""A 404 Not Found server error."""
class ChefAPIVersionError(ChefError):
"""An incompatible API version error"""
class ChefObjectTypeError(ChefError):
"""An invalid object type error"""
class ChefUnsupportedEncryptionVersionError(ChefError):
def __init__(self, version):
message = "This version of chef does not support encrypted data bag item format version %s" % version
return super(ChefError, self).__init__(message)
class ChefDecryptionError(ChefError):
"""Error decrypting data bag value. Most likely the provided key is incorrect"""