forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexceptions.py
56 lines (42 loc) · 1.54 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
"""
This module contains exceptions that may be raised in El Proxito application
but are handled elsewhere in the Django project.
--------------
404 exceptions
--------------
Because an Http404 can be raised anywhere in the code,
we want to add more context for targeted error handling and user-facing communication
"""
from django.http.response import Http404
class ProxitoHttp404(Http404):
"""
General error class for proxity 404s
"""
def __init__(self, message):
super().__init__(message)
class ProxitoProjectHttp404(ProxitoHttp404):
"""
Raised if a project was not found
"""
def __init__(self, message, project_slug=None):
self.project_slug = project_slug
super().__init__(message)
class ProxitoSubProjectHttp404(ProxitoProjectHttp404):
"""
Raised if a sub-project was not found
"""
def __init__(self, message, project_slug=None, project=None, subproject_slug=None):
self.project_slug = project_slug
self.project = project
self.subproject_slug = subproject_slug
super().__init__(message)
class ProxitoProjectPageHttp404(ProxitoHttp404):
"""
Raised if a page inside an existing project was not found
Note: The containing project can be both a project or a subproject inside another project
"""
def __init__(self, message, project_slug=None, project=None, subproject_slug=None):
self.project_slug = project_slug
self.project = project
self.subproject_slug = subproject_slug
super().__init__(message)