forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexceptions.py
86 lines (63 loc) · 2.2 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Exceptions for El Proxito.
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."""
class ProxitoProjectHttp404(ProxitoHttp404):
"""Raised if a project was not found."""
def __init__(self, message, project_slug=None, proxito_path=None):
self.project_slug = project_slug
self.proxito_path = proxito_path
super().__init__(message)
class ProxitoSubProjectHttp404(ProxitoProjectHttp404):
"""Raised if a subproject was not found."""
def __init__(
self,
message,
project_slug=None,
proxito_path=None,
project=None,
subproject_slug=None,
):
super().__init__(message, project_slug=project_slug, proxito_path=proxito_path)
self.project = project
self.subproject_slug = subproject_slug
class ProxitoProjectPageHttp404(ProxitoProjectHttp404):
"""Raised if a page inside an existing project was not found."""
def __init__(
self,
message,
project_slug=None,
proxito_path=None,
project=None,
subproject_slug=None,
):
super().__init__(message, project_slug=project_slug, proxito_path=proxito_path)
self.project = project
self.subproject_slug = subproject_slug
class ProxitoProjectVersionHttp404(ProxitoProjectHttp404):
"""
Raised if a version 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,
proxito_path=None,
project=None,
subproject_slug=None,
version_slug=None,
):
super().__init__(message, project_slug=project_slug, proxito_path=proxito_path)
self.project = project
self.subproject_slug = subproject_slug
self.version_slug = version_slug