Show More
The requested changes are too big and content was truncated. Show full diff
@@ -1,159 +1,171 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2019 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | """ |
|
22 | 22 | Set of custom exceptions used in RhodeCode |
|
23 | 23 | """ |
|
24 | 24 | |
|
25 | 25 | from webob.exc import HTTPClientError |
|
26 | 26 | from pyramid.httpexceptions import HTTPBadGateway |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | class LdapUsernameError(Exception): |
|
30 | 30 | pass |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | class LdapPasswordError(Exception): |
|
34 | 34 | pass |
|
35 | 35 | |
|
36 | 36 | |
|
37 | 37 | class LdapConnectionError(Exception): |
|
38 | 38 | pass |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | class LdapImportError(Exception): |
|
42 | 42 | pass |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | class DefaultUserException(Exception): |
|
46 | 46 | pass |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | class UserOwnsReposException(Exception): |
|
50 | 50 | pass |
|
51 | 51 | |
|
52 | 52 | |
|
53 | 53 | class UserOwnsRepoGroupsException(Exception): |
|
54 | 54 | pass |
|
55 | 55 | |
|
56 | 56 | |
|
57 | 57 | class UserOwnsUserGroupsException(Exception): |
|
58 | 58 | pass |
|
59 | 59 | |
|
60 | 60 | |
|
61 | 61 | class UserGroupAssignedException(Exception): |
|
62 | 62 | pass |
|
63 | 63 | |
|
64 | 64 | |
|
65 | 65 | class StatusChangeOnClosedPullRequestError(Exception): |
|
66 | 66 | pass |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | class AttachedForksError(Exception): |
|
70 | 70 | pass |
|
71 | 71 | |
|
72 | 72 | |
|
73 | 73 | class AttachedPullRequestsError(Exception): |
|
74 | 74 | pass |
|
75 | 75 | |
|
76 | 76 | |
|
77 | 77 | class RepoGroupAssignmentError(Exception): |
|
78 | 78 | pass |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | class NonRelativePathError(Exception): |
|
82 | 82 | pass |
|
83 | 83 | |
|
84 | 84 | |
|
85 | 85 | class HTTPRequirementError(HTTPClientError): |
|
86 | 86 | title = explanation = 'Repository Requirement Missing' |
|
87 | 87 | reason = None |
|
88 | 88 | |
|
89 | 89 | def __init__(self, message, *args, **kwargs): |
|
90 | 90 | self.title = self.explanation = message |
|
91 | 91 | super(HTTPRequirementError, self).__init__(*args, **kwargs) |
|
92 | 92 | self.args = (message, ) |
|
93 | 93 | |
|
94 | 94 | |
|
95 | 95 | class HTTPLockedRC(HTTPClientError): |
|
96 | 96 | """ |
|
97 | 97 | Special Exception For locked Repos in RhodeCode, the return code can |
|
98 | 98 | be overwritten by _code keyword argument passed into constructors |
|
99 | 99 | """ |
|
100 | 100 | code = 423 |
|
101 | 101 | title = explanation = 'Repository Locked' |
|
102 | 102 | reason = None |
|
103 | 103 | |
|
104 | 104 | def __init__(self, message, *args, **kwargs): |
|
105 | 105 | from rhodecode import CONFIG |
|
106 | 106 | from rhodecode.lib.utils2 import safe_int |
|
107 | 107 | _code = CONFIG.get('lock_ret_code') |
|
108 | 108 | self.code = safe_int(_code, self.code) |
|
109 | 109 | self.title = self.explanation = message |
|
110 | 110 | super(HTTPLockedRC, self).__init__(*args, **kwargs) |
|
111 | 111 | self.args = (message, ) |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | class HTTPBranchProtected(HTTPClientError): |
|
115 | 115 | """ |
|
116 | 116 | Special Exception For Indicating that branch is protected in RhodeCode, the |
|
117 | 117 | return code can be overwritten by _code keyword argument passed into constructors |
|
118 | 118 | """ |
|
119 | 119 | code = 403 |
|
120 | 120 | title = explanation = 'Branch Protected' |
|
121 | 121 | reason = None |
|
122 | 122 | |
|
123 | 123 | def __init__(self, message, *args, **kwargs): |
|
124 | 124 | self.title = self.explanation = message |
|
125 | 125 | super(HTTPBranchProtected, self).__init__(*args, **kwargs) |
|
126 | 126 | self.args = (message, ) |
|
127 | 127 | |
|
128 | 128 | |
|
129 | 129 | class IMCCommitError(Exception): |
|
130 | 130 | pass |
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | class UserCreationError(Exception): |
|
134 | 134 | pass |
|
135 | 135 | |
|
136 | 136 | |
|
137 | 137 | class NotAllowedToCreateUserError(Exception): |
|
138 | 138 | pass |
|
139 | 139 | |
|
140 | 140 | |
|
141 | 141 | class RepositoryCreationError(Exception): |
|
142 | 142 | pass |
|
143 | 143 | |
|
144 | 144 | |
|
145 | 145 | class VCSServerUnavailable(HTTPBadGateway): |
|
146 | 146 | """ HTTP Exception class for VCS Server errors """ |
|
147 | 147 | code = 502 |
|
148 | 148 | title = 'VCS Server Error' |
|
149 | 149 | causes = [ |
|
150 | 150 | 'VCS Server is not running', |
|
151 | 151 | 'Incorrect vcs.server=host:port', |
|
152 | 152 | 'Incorrect vcs.server.protocol', |
|
153 | 153 | ] |
|
154 | 154 | |
|
155 | 155 | def __init__(self, message=''): |
|
156 | 156 | self.explanation = 'Could not connect to VCS Server' |
|
157 | 157 | if message: |
|
158 | 158 | self.explanation += ': ' + message |
|
159 | 159 | super(VCSServerUnavailable, self).__init__() |
|
160 | ||
|
161 | ||
|
162 | class ArtifactMetadataDuplicate(ValueError): | |
|
163 | ||
|
164 | def __init__(self, *args, **kwargs): | |
|
165 | self.err_section = kwargs.pop('err_section', None) | |
|
166 | self.err_key = kwargs.pop('err_key', None) | |
|
167 | super(ArtifactMetadataDuplicate, self).__init__(*args, **kwargs) | |
|
168 | ||
|
169 | ||
|
170 | class ArtifactMetadataBadValueType(ValueError): | |
|
171 | pass |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now