~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merged bug-824435-failure-reporting-2 into bug-824435-failure-reporting-3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
__metaclass__ = type
7
7
__all__ = [
 
8
    'AlreadyLatestFormat',
8
9
    'BadBranchMergeProposalSearchContext',
9
10
    'BadStateTransition',
10
11
    'BranchCannotBePrivate',
20
21
    'BuildNotAllowedForDistro',
21
22
    'BranchMergeProposalExists',
22
23
    'CannotDeleteBranch',
 
24
    'CannotUpgradeBranch',
 
25
    'CannotUpgradeNonHosted',
23
26
    'CannotHaveLinkedBranch',
24
27
    'CodeImportAlreadyRequested',
25
28
    'CodeImportAlreadyRunning',
36
39
    'TooManyBuilds',
37
40
    'TooNewRecipeFormat',
38
41
    'UnknownBranchTypeError',
 
42
    'UpgradePending',
39
43
    'UserHasExistingReview',
40
44
    'UserNotBranchReviewer',
41
45
    'WrongBranchMergeProposal',
56
60
    """The context is not valid for a branch merge proposal search."""
57
61
 
58
62
 
 
63
@error_status(httplib.BAD_REQUEST)
59
64
class BadStateTransition(Exception):
60
65
    """The user requested a state transition that is not possible."""
61
66
 
167
172
    _msg_template = "%s cannot have linked branches."
168
173
 
169
174
 
 
175
class CannotUpgradeBranch(Exception):
 
176
    """"Made for subclassing."""
 
177
 
 
178
    def __init__(self, branch):
 
179
        super(CannotUpgradeBranch, self).__init__(
 
180
            self._msg_template % branch.bzr_identity)
 
181
        self.branch = branch
 
182
 
 
183
 
 
184
class AlreadyLatestFormat(CannotUpgradeBranch):
 
185
    """Raised on attempt to upgrade a branch already in the latest format."""
 
186
 
 
187
    _msg_template = (
 
188
        'Branch %s is in the latest format, so it cannot be upgraded.')
 
189
 
 
190
 
 
191
class CannotUpgradeNonHosted(CannotUpgradeBranch):
 
192
 
 
193
    """Raised on attempt to upgrade a non-Hosted branch."""
 
194
 
 
195
    _msg_template = 'Cannot upgrade non-hosted branch %s'
 
196
 
 
197
 
 
198
class UpgradePending(CannotUpgradeBranch):
 
199
 
 
200
    """Raised on attempt to upgrade a branch already in the latest format."""
 
201
 
 
202
    _msg_template = 'An upgrade is already in progress for branch %s.'
 
203
 
 
204
 
170
205
class ClaimReviewFailed(Exception):
171
206
    """The user cannot claim the pending review."""
172
207