~allenap/maas/backup

« back to all changes in this revision

Viewing changes to src/maasserver/exceptions.py

  • Committer: Gavin Panella
  • Date: 2012-03-15 13:58:32 UTC
  • mto: This revision was merged to the branch mainline in revision 291.
  • Revision ID: gavin.panella@canonical.com-20120315135832-8i2rkbvp6gwdhkzt
Change MaaS to MAAS everywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
__metaclass__ = type
12
12
__all__ = [
13
 
    "MaaSException",
14
 
    "MaaSAPIBadRequest",
15
 
    "MaaSAPIException",
16
 
    "MaaSAPINotFound",
 
13
    "MAASException",
 
14
    "MAASAPIBadRequest",
 
15
    "MAASAPIException",
 
16
    "MAASAPINotFound",
17
17
    "NodeStateViolation",
18
18
    "PermissionDenied",
19
19
    ]
22
22
import httplib
23
23
 
24
24
 
25
 
class MaaSException(Exception):
26
 
    """Base class for MaaS' exceptions."""
 
25
class MAASException(Exception):
 
26
    """Base class for MAAS' exceptions."""
27
27
 
28
28
 
29
29
class CannotDeleteUserException(Exception):
30
30
    """User can't be deleted."""
31
31
 
32
32
 
33
 
class MaaSAPIException(Exception):
34
 
    """Base class for MaaS' API exceptions.
 
33
class MAASAPIException(Exception):
 
34
    """Base class for MAAS' API exceptions.
35
35
 
36
36
    :ivar api_error: The HTTP code that should be returned when this error
37
37
        is raised in the API (defaults to 500: "Internal Server Error").
40
40
    api_error = httplib.INTERNAL_SERVER_ERROR
41
41
 
42
42
 
43
 
class MaaSAPIBadRequest(MaaSAPIException):
 
43
class MAASAPIBadRequest(MAASAPIException):
44
44
    api_error = httplib.BAD_REQUEST
45
45
 
46
46
 
47
 
class MaaSAPINotFound(MaaSAPIException):
 
47
class MAASAPINotFound(MAASAPIException):
48
48
    api_error = httplib.NOT_FOUND
49
49
 
50
50
 
51
 
class PermissionDenied(MaaSAPIException):
 
51
class PermissionDenied(MAASAPIException):
52
52
    """HTTP error 403: Forbidden.  User is logged in, but lacks permission.
53
53
 
54
54
    Do not confuse this with 401: Unauthorized ("you need to be logged in
58
58
    api_error = httplib.FORBIDDEN
59
59
 
60
60
 
61
 
class Unauthorized(MaaSAPIException):
 
61
class Unauthorized(MAASAPIException):
62
62
    """HTTP error 401: Unauthorized.  Login required."""
63
63
    api_error = httplib.UNAUTHORIZED
64
64
 
65
65
 
66
 
class NodeStateViolation(MaaSAPIException):
 
66
class NodeStateViolation(MAASAPIException):
67
67
    """Operation on node not possible given node's current state."""
68
68
    api_error = httplib.CONFLICT
69
69