~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/errors.py

  • Committer: Julian Edwards
  • Date: 2011-07-28 20:46:18 UTC
  • mfrom: (13553 devel)
  • mto: This revision was merged to the branch mainline in revision 13555.
  • Revision ID: julian.edwards@canonical.com-20110728204618-tivj2wx2oa9s32bx
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Errors used in the lp/code modules."""
5
5
 
6
6
__metaclass__ = type
7
7
__all__ = [
8
 
    'AlreadyLatestFormat',
9
8
    'BadBranchMergeProposalSearchContext',
10
9
    'BadStateTransition',
11
10
    'BranchCannotBePrivate',
15
14
    'BranchCreatorNotMemberOfOwnerTeam',
16
15
    'BranchCreatorNotOwner',
17
16
    'BranchExists',
18
 
    'BranchHasPendingWrites',
19
17
    'BranchTargetError',
20
18
    'BranchTypeError',
21
19
    'BuildAlreadyPending',
22
20
    'BuildNotAllowedForDistro',
23
21
    'BranchMergeProposalExists',
24
22
    'CannotDeleteBranch',
25
 
    'CannotUpgradeBranch',
26
 
    'CannotUpgradeNonHosted',
27
23
    'CannotHaveLinkedBranch',
28
24
    'CodeImportAlreadyRequested',
29
25
    'CodeImportAlreadyRunning',
40
36
    'TooManyBuilds',
41
37
    'TooNewRecipeFormat',
42
38
    'UnknownBranchTypeError',
43
 
    'UpdatePreviewDiffNotReady',
44
 
    'UpgradePending',
45
39
    'UserHasExistingReview',
46
40
    'UserNotBranchReviewer',
47
41
    'WrongBranchMergeProposal',
62
56
    """The context is not valid for a branch merge proposal search."""
63
57
 
64
58
 
65
 
@error_status(httplib.BAD_REQUEST)
66
59
class BadStateTransition(Exception):
67
60
    """The user requested a state transition that is not possible."""
68
61
 
94
87
        BranchCreationException.__init__(self, message)
95
88
 
96
89
 
97
 
class BranchHasPendingWrites(Exception):
98
 
    """Raised if the branch can't be processed because a write is pending.
99
 
 
100
 
    In this case the operation can usually be retried in a while.
101
 
 
102
 
    See bug 612171.
103
 
    """
104
 
 
105
 
 
106
90
class BranchTargetError(Exception):
107
91
    """Raised when there is an error determining a branch target."""
108
92
 
183
167
    _msg_template = "%s cannot have linked branches."
184
168
 
185
169
 
186
 
class CannotUpgradeBranch(Exception):
187
 
    """"Made for subclassing."""
188
 
 
189
 
    def __init__(self, branch):
190
 
        super(CannotUpgradeBranch, self).__init__(
191
 
            self._msg_template % branch.bzr_identity)
192
 
        self.branch = branch
193
 
 
194
 
 
195
 
class AlreadyLatestFormat(CannotUpgradeBranch):
196
 
    """Raised on attempt to upgrade a branch already in the latest format."""
197
 
 
198
 
    _msg_template = (
199
 
        'Branch %s is in the latest format, so it cannot be upgraded.')
200
 
 
201
 
 
202
 
class CannotUpgradeNonHosted(CannotUpgradeBranch):
203
 
 
204
 
    """Raised on attempt to upgrade a non-Hosted branch."""
205
 
 
206
 
    _msg_template = 'Cannot upgrade non-hosted branch %s'
207
 
 
208
 
 
209
 
class UpgradePending(CannotUpgradeBranch):
210
 
 
211
 
    """Raised on attempt to upgrade a branch already in the latest format."""
212
 
 
213
 
    _msg_template = 'An upgrade is already in progress for branch %s.'
214
 
 
215
 
 
216
170
class ClaimReviewFailed(Exception):
217
171
    """The user cannot claim the pending review."""
218
172
 
295
249
    """The requested review is not in a pending state."""
296
250
 
297
251
 
298
 
class UpdatePreviewDiffNotReady(Exception):
299
 
    """Raised if the the preview diff is not ready to run."""
300
 
 
301
 
 
302
252
class UserHasExistingReview(Exception):
303
253
    """The user has an existing review."""
304
254