120
120
# base classes should override the docstring with their human-
121
121
# readable explanation
123
def __init__(self, **kwds):
123
def __init__(self, *args, **kwds):
124
# XXX: Use the underlying BzrError to always generate the args attribute
125
# if it doesn't exist. We can't use super here, because exceptions are
126
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
127
BzrError.__init__(self, *args)
124
128
for key, value in kwds.items():
125
129
setattr(self, key, value)
132
136
if isinstance(s, unicode):
133
137
return s.encode('utf8')
135
except (NameError, ValueError, KeyError), e:
136
return 'Unprintable exception %s: %s' \
137
% (self.__class__.__name__, str(e))
139
except (TypeError, NameError, ValueError, KeyError), e:
140
return 'Unprintable exception %s(%r): %s' \
141
% (self.__class__.__name__,
142
self.__dict__, str(e))
145
class AlreadyBuilding(BzrNewError):
146
"""The tree builder is already building a tree."""
140
149
class BzrCheckError(BzrNewError):
167
176
class InvalidRevisionId(BzrNewError):
168
177
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
169
179
def __init__(self, revision_id, branch):
170
180
# branch can be any string or object with __str__ defined
171
181
BzrNewError.__init__(self)
173
183
self.branch = branch
186
class NoSuchId(BzrNewError):
187
"""The file id %(file_id)s is not present in the tree %(tree)s."""
189
def __init__(self, tree, file_id):
190
BzrNewError.__init__(self)
191
self.file_id = file_id
176
195
class NoWorkingTree(BzrNewError):
177
196
"""No WorkingTree exists for %(base)s."""
265
288
def __init__(self, msg, base, args):
266
289
PathError.__init__(self, base, msg)
268
self.args.extend(args)
290
self.args = [base] + list(args)
271
293
class UnsupportedProtocol(PathError):
275
297
PathError.__init__(self, url, extra=extra)
300
class ShortReadvError(PathError):
301
"""readv() read %(actual)s bytes rather than %(length)s bytes at %(offset)s for %(path)s%(extra)s"""
303
is_user_error = False
305
def __init__(self, path, offset, length, actual, extra=None):
306
PathError.__init__(self, path, extra=extra)
278
312
class PathNotChild(BzrNewError):
279
313
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
364
398
self.bzrdir = bzrdir_format
401
class IncompatibleRevision(BzrNewError):
402
"""Revision is not compatible with %(repo_format)s"""
404
def __init__(self, repo_format):
405
BzrNewError.__init__(self)
406
self.repo_format = repo_format
367
409
class NotVersionedError(BzrNewError):
368
410
"""%(path)s is not versioned"""
369
411
def __init__(self, path):
515
556
is_user_error = False
517
558
def __init__(self, branch, revision):
519
self.revision = revision
559
BzrNewError.__init__(self, branch=branch, revision=revision)
562
class NoSuchRevisionSpec(BzrNewError):
563
"""No namespace registered for string: %(spec)r"""
565
def __init__(self, spec):
566
BzrNewError.__init__(self, spec=spec)
569
class InvalidRevisionSpec(BzrNewError):
570
"""Requested revision: '%(spec)s' does not exist in branch:
571
%(branch)s%(extra)s"""
573
def __init__(self, spec, branch, extra=None):
574
BzrNewError.__init__(self, branch=branch, spec=spec)
576
self.extra = '\n' + str(extra)
522
581
class HistoryMissing(BzrError):
585
644
self.bases = bases
588
class NoCommits(BzrError):
647
class NoCommits(BzrNewError):
648
"""Branch %(branch)s has no commits."""
589
650
def __init__(self, branch):
590
msg = "Branch %s has no commits." % branch
591
BzrError.__init__(self, msg)
651
BzrNewError.__init__(self, branch=branch)
594
654
class UnlistableStore(BzrError):
762
822
BzrNewError.__init__(self)
825
class SmartProtocolError(TransportError):
826
"""Generic bzr smart protocol error: %(details)s"""
828
def __init__(self, details):
829
self.details = details
765
832
# A set of semi-meaningful errors which can be thrown
766
833
class TransportNotPossible(TransportError):
767
"""Transport operation not possible: %(msg)s %(orig_error)%"""
834
"""Transport operation not possible: %(msg)s %(orig_error)s"""
770
837
class ConnectionError(TransportError):
778
845
class InvalidRange(TransportError):
779
"""Invalid range access."""
846
"""Invalid range access in %(path)s at %(offset)s."""
781
848
def __init__(self, path, offset):
782
849
TransportError.__init__(self, ("Invalid range access in %s at %d"
783
850
% (path, offset)))
786
855
class InvalidHttpResponse(TransportError):
956
1029
self.format = format
1032
class BadConversionTarget(BzrNewError):
1033
"""Cannot convert to format %(format)s. %(problem)s"""
1035
def __init__(self, problem, format):
1036
BzrNewError.__init__(self)
1037
self.problem = problem
1038
self.format = format
959
1041
class NoDiff(BzrNewError):
960
1042
"""Diff is not installed on this machine: %(msg)s"""
1106
1188
BzrNewError.__init__(self)
1107
1189
self.text = text
1109
1192
class UnsupportedEOLMarker(BadBundle):
1110
1193
"""End of line marker was not \\n in bzr revision-bundle"""
1112
1195
def __init__(self):
1113
BzrNewError.__init__(self)
1196
BzrNewError.__init__(self)
1199
class IncompatibleFormat(BzrNewError):
1200
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1202
def __init__(self, bundle_format, other):
1203
BzrNewError.__init__(self)
1204
self.bundle_format = bundle_format
1208
class BadInventoryFormat(BzrNewError):
1209
"""Root class for inventory serialization errors"""
1212
class UnexpectedInventoryFormat(BadInventoryFormat):
1213
"""The inventory was not in the expected format:\n %(msg)s"""
1215
def __init__(self, msg):
1216
BadInventoryFormat.__init__(self, msg=msg)
1219
class NoSmartServer(NotBranchError):
1220
"""No smart server available at %(url)s"""
1222
def __init__(self, url):
1226
class UnknownSSH(BzrNewError):
1227
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1229
def __init__(self, vendor):
1230
BzrNewError.__init__(self)
1231
self.vendor = vendor
1234
class GhostRevisionUnusableHere(BzrNewError):
1235
"""Ghost revision {%(revision_id)s} cannot be used here."""
1237
def __init__(self, revision_id):
1238
BzrNewError.__init__(self)
1239
self.revision_id = revision_id
1242
class IllegalUseOfScopeReplacer(BzrNewError):
1243
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1245
is_user_error = False
1247
def __init__(self, name, msg, extra=None):
1248
BzrNewError.__init__(self)
1252
self.extra = ': ' + str(extra)
1257
class InvalidImportLine(BzrNewError):
1258
"""Not a valid import statement: %(msg)\n%(text)s"""
1260
is_user_error = False
1262
def __init__(self, text, msg):
1263
BzrNewError.__init__(self)
1268
class ImportNameCollision(BzrNewError):
1269
"""Tried to import an object to the same name as an existing object. %(name)s"""
1271
is_user_error = False
1273
def __init__(self, name):
1274
BzrNewError.__init__(self)