-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathexceptions.py
More file actions
45 lines (32 loc) · 1.07 KB
/
exceptions.py
File metadata and controls
45 lines (32 loc) · 1.07 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
44
45
"""
Deis API exception classes.
"""
from __future__ import unicode_literals
from rest_framework.exceptions import APIException
from rest_framework import status
class AbstractDeisException(APIException):
"""
Abstract class in which all Deis Exceptions and Errors should extend.
This exception is subclassed from rest_framework's APIException so that
subclasses can change the status code to something different than
"500 SERVER ERROR."
"""
def __init__(self, detail=None):
self.detail = detail
class Meta:
abstract = True
class BuildNodeError(AbstractDeisException):
"""
Indicates a problem in building or bootstrapping a node.
"""
status_code = status.HTTP_401_UNAUTHORIZED
class BuildFormationError(AbstractDeisException):
"""
Indicates a problem in creating a formation.
"""
status_code = status.HTTP_400_BAD_REQUEST
class UserRegistrationException(AbstractDeisException):
"""
Indicates that there was a problem registering the user.
"""
status_code = status.HTTP_400_BAD_REQUEST