23
23
######################################################################
25
25
class BzrError(StandardError):
27
if len(self.args) == 1:
29
elif len(self.args) == 2:
30
# further explanation or suggestions
31
return '\n '.join([self.args[0]] + self.args[1])
28
36
class BzrCheckError(BzrError):
34
def bailout(msg, explanation=[]):
35
ex = BzrError(msg, explanation)
37
trace._tracefile.write('* raising %s\n' % ex)
40
class InvalidRevisionNumber(BzrError):
41
def __init__(self, revno):
45
return 'invalid revision number: %r' % self.args[0]
48
class InvalidRevisionId(BzrError):
52
class BzrCommandError(BzrError):
53
# Error from malformed user command
57
class NotBranchError(BzrError):
58
"""Specified path is not in a branch"""
62
class NotVersionedError(BzrError):
63
"""Specified object is not versioned."""
66
class BadFileKindError(BzrError):
67
"""Specified file is of a kind that cannot be added.
69
(For example a symlink or device file.)"""
73
class ForbiddenFileError(BzrError):
74
"""Cannot operate on a file because it is a control file."""
78
class LockError(Exception):
79
"""All exceptions from the lock/unlock functions should be from
80
this exception class. They will be translated as necessary. The
81
original exception is available as e.original_error
83
def __init__(self, e=None):
84
self.original_error = e
86
Exception.__init__(self, e)
88
Exception.__init__(self)
91
class PointlessCommit(Exception):
92
"""Commit failed because nothing was changed."""
95
class NoSuchRevision(BzrError):
96
def __init__(self, branch, revision):
98
self.revision = revision
99
msg = "Branch %s has no revision %s" % (branch, revision)
100
BzrError.__init__(self, msg)
103
class HistoryMissing(BzrError):
104
def __init__(self, branch, object_type, object_id):
106
BzrError.__init__(self,
107
'%s is missing %s {%s}'
108
% (branch, object_type, object_id))
111
class UnrelatedBranches(BzrCommandError):
113
msg = "Branches have no common ancestor, and no base revision"\
115
BzrCommandError.__init__(self, msg)
118
class NotAncestor(BzrError):
119
def __init__(self, rev_id, not_ancestor_id):
121
self.not_ancestor_id = not_ancestor_id
122
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
124
BzrError.__init__(self, msg)
127
class InstallFailed(BzrError):
128
def __init__(self, revisions):
129
self.revisions = revisions
130
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
131
BzrError.__init__(self, msg)
134
class AmbiguousBase(BzrError):
135
def __init__(self, bases):
136
msg = "The correct base is unclear, becase %s are all equally close" %\
138
BzrError.__init__(self, msg)